网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
单选题
11. public void someMethod(Object value) { 12. // check for null value .... 20. System.out.println(value.getClass()); 21. } What, inserted at line 12, is the appropriate way to handle a null value?()
A
assert value == null;
B
assert value !null, “value is null”;
C
if (value == null) { throw new AssertionException(”value is null”);
D
if (value == null) { throw new IllegalArgumentException(”value is null”);
参考答案
参考解析
解析:
暂无解析
更多 “单选题11. public void someMethod(Object value) { 12. // check for null value .... 20. System.out.println(value.getClass()); 21. } What, inserted at line 12, is the appropriate way to handle a null value?()A assert value == null;B assert value !null, “value is null”;C if (value == null) { throw new AssertionException(”value is null”);D if (value == null) { throw new IllegalArgumentException(”value is null”);” 相关考题
考题
下列关于Test类的定义中,正确的是______。A) class Test implements Runnabte{public void run(){}public void someMethod(){}B) class Test implements Rnuuable{public void run();}C) class Test implements Rnuuable{public void someMethod();}D) class Test implements Rnuuable{public void someMethod();{}}A.B.C.D.
考题
1.public class GC{2.private Objec to;3.private void doSomethingElse(Object obj){o=obj;}4.public void doSomething(){5.Object o=new Object();6.doSomethingElse(o);7.o=new Object();8.doSomethingElse(null);9.o=null;10.}11.}When the doSomething method is called,after which line does the Object created in line 5 become available for garbage collection?()A.Line5B.Line6C.Line7D.Line8E.Line9F.Line10
考题
下列关于Test类的定义中,正确的是( )。A.class Test implements Runnable{ public void run{} Dublic void someMethod[]{} }B.class Test implements Runnable( puIblic void run; }C.class Test implements Runnable( Dublic void someMethod[]; }D.class Test implements Runnable( public void someMethod{} }
考题
10. public class ClassA { 11. public void count(int i) { 12. count(++i); 13. } 14. } And: 20. ClassA a = new ClassA(); 21. a.count(3); Which exception or error should be thrown by the virtual machine?() A、 StackOverflowErrorB、 NullPointerExceptionC、 NumberFormatExceptionD、 IllegalArgumentExceptionE、 ExceptionlnlnitializerError
考题
11. public static void main(String[] args) { 12. Object obj = new Object() { 13. public int hashCode() { 14. returns 42; 15. } 16. }; 17. System.out.println(obj.hashCode()); 18. } What is the result? () A、 42B、 An exception is thrown at runtime.C、 Compilation fails because of an error on line 12.D、 Compilation fails because of an error on line 16.E、 Compilation fails because of an error on line 17.
考题
在j2ee中,以下是firevetoablechange方法的正确的原型的是() A、public void fireVetoableChange(Object oldValue,Object newValue)B、 public void fireVetoableChange(String propertyName,Object newValue)C、 public void fireVetoableChange(String propertyName, Object oldValue ,Object newValue)throws PropertyVetoExceptionD、 public void fireVetoableChange(String propertyName, Object oldValue ,Object newValue)
考题
在J2EE中,以下是firePropertyChange的原型,正确的是()。 A、public void firePropertyChange(PropertyChangeListener l,String oldValue, String newValue)B、public void firePropertyChange(String propertyName, Object oldValue, Object newValue)C、public void firePropertyChange(PropertyChangeSupport changes)D、public void firePropertyChange(Object oldValue, Object newValue)
考题
下列代码正确的是哪项?() A、 public class Session implements Runnable, Clonable{ public void run ();public Object clone () ; }B、 public class Session extends Runnable, Cloneable { public void run() {/*dosomething*/} public Object clone() {/*make a copy*/} }C、 public abstract class Session implements Runnable, Clonable { public void run() {/*do something*/} public Object clone() {/*make a copy*/} }D、 public class Session implements Runnable, implements Clonable { public void run() {/*do something*/} public Object clone() {/*make a copy*/} }
考题
11. public class Test { 12. public void foo() { 13. assert false; 14. assert false; 15. } 16. public void bar(){ 17. while(true){ 18. assert false; 19. } 20. assert false; 21. } 22. } What causes compilation to fail?() A、 Line 13B、 Line 14C、 Line 18D、 Line 20
考题
11. public interface Status { 12. /* insert code here */ int MY_VALUE = 10; 13. } Which three are valid on line 12?()A、 finalB、 staticC、 nativeD、 publicE、 privateF、 abstractG、 protected
考题
11. public void someMethod(Object value) { 12. // check for null value .... 20. System.out.println(value.getClass()); 21. } What, inserted at line 12, is the appropriate way to handle a null value?() A、 assert value == null;B、 assert value !null, “value is null”;C、 if (value == null) { throw new AssertionException(”value is null”);D、 if (value == null) { throw new IllegalArgumentException(”value is null”);
考题
1. public class test ( 2. public static void main(string args[]) { 3. int 1= 0; 4. while (i) { 5. if (i==4) { 6. break; 7. } 8. ++i; 9. } 10. 11. } 12. ) What is the value of i at line 10?()A、 0B、 3C、 4D、 5E、 The code will not compile.
考题
单选题1.public class GC{ 2.private Objec to; 3.private void doSomethingElse(Object obj){o=obj;} 4.public void doSomething(){ 5.Object o=new Object(); 6.doSomethingElse(o); 7.o=new Object(); 8.doSomethingElse(null); 9.o=null; 10.} 11.} When the doSomething method is called,after which line does the Object created in line 5 become available for garbage collection?()A
Line5B
Line6C
Line7D
Line8E
Line9F
Line10
考题
单选题下列代码正确的是哪项?()A
public class Session implements Runnable, Clonable{ public void run ();public Object clone () ; }B
public class Session extends Runnable, Cloneable { public void run() {/*dosomething*/} public Object clone() {/*make a copy*/} }C
public abstract class Session implements Runnable, Clonable { public void run() {/*do something*/} public Object clone() {/*make a copy*/} }D
public class Session implements Runnable, implements Clonable { public void run() {/*do something*/} public Object clone() {/*make a copy*/} }
考题
单选题11. public void someMethod(Object value) { 12. // check for null value .... 20. System.out.println(value.getClass()); 21. } What, inserted at line 12, is the appropriate way to handle a null value?()A
assert value == null;B
assert value !null, “value is null”;C
if (value == null) { throw new AssertionException(”value is null”);D
if (value == null) { throw new IllegalArgumentException(”value is null”);
考题
单选题1. public class SimpleCalc { 2. public int value; 3. public void calculate() { value += 7; } 4. } And: 1. public class MultiCalc extends SimpleCalc { 2. public void calculate() { value -= 3; } 3. public void calculate(int multiplier) { 4. calculate(); 5. super.calculate(); 6. value *=multiplier; 7. } 8. public static void main(String[] args) { 9. MultiCalc calculator = new MultiCalc(); 10. calculator.calculate(2); 11. System.out.println(”Value is: “+ calculator.value); 12. } 13. } What is the result?()A
Value is: 8B
Compilation fails.C
Value is: 12D
Value is: -12E
The code runs with no output.F
An exception is thrown at runtime.
考题
单选题public class ItemTest { private final mt id; public ItemTest(int id) { this.id = id; } public void updateId(int newId) { id = newId; } public static void main(String[] args) { ItemTest fa = new ItemTest(42); fa.updateId(69); System.out.println(fa.id); } } What is the result?()A
Compilation fails.B
An exception is thrown at runtime.C
The attribute id in the Item object remains unchanged.D
The attribute id in the Item object is modified to the new value.E
A new Item object is created with the preferred value in the id attribute.
考题
单选题Given: 11. public void genNumbers() { 12. ArrayList numbers = new ArrayList(); 13. for (int i=0; i10; i++) { 14. int value = i * ((int) Math.random()); 15. Integer intObj = new Integer(value); 16. numbers.add(intObj); 17. } 18. System.out.println(numbers); 19. } Which line of code marks the earliest point that an object referenced by intObj becomes a candidate for garbage collection?()A
Line 19B
The object is NOT a candidate for garbage collection.C
Line 17D
Line 16E
Line 18
考题
单选题1. public class GC { 2. private Object o; 3. private void doSomethingElse(Object obj) { o = obj; } 4. public void doSomething() { 5. Object o = new Object(); 6. doSomethingElse(o); 7. o = new Object(); 8. doSomethingElse(null); 9.o=null; 10. } 11. } When the doSomething method is called, after which line does the Object created in line 5 become available for garbage collection?()A
Line 5B
Line 6C
Line 7D
Line 8E
Line 9F
Line 10
考题
单选题Given a method that must ensure that its parameter is not null: 11. public void someMethod(Object value) { 12. // check for null value ... 20. System.out.println(value.getClass()); 21. } What inserted at line 12, is the appropriate way to handle a null value?()A
assert value == null;B
assert value != null, value is null;C
if (value == null) { throw new AssertionException(value is null); }D
if (value == null) { throw new IllegalArgumentException(value is null); }
考题
单选题1. public class SwitchTest { 2. public static void main (String []args) { 3. System.out.PrintIn(“value =” +switchIt(4)); 4. } 5. public static int switchIt(int x) { 6. int j = 1; 7. switch (x) { 8. case 1: j++; 9. case 2: j++; 10. case 3: j++; 11. case 4: j++; 12. case 5: j++; 13. default:j++; 14. } 15. return j + x; 16. } 17. } What is the output from line 3?()A
Value = 3B
Value = 4C
Value = 5D
Value = 6E
Value = 7F
Value = 8
考题
单选题11. public static void main(String[] args) { 12. Object obj = new Object() { 13. public int hashCode() { 14. returns 42; 15. } 16. }; 17. System.out.println(obj.hashCode()); 18. } What is the result? ()A
42B
An exception is thrown at runtime.C
Compilation fails because of an error on line 12.D
Compilation fails because of an error on line 16.E
Compilation fails because of an error on line 17.
考题
单选题Given: 11. public static void main(String[] args) { 12. Object obj = new int[] { 1, 2, 3 }; 13. int[] someArray = (int[])obj; 14. for (int i : someArray) System.out.print(i + " "); 15. } What is the result? ()A
Compilation fails because of an error in line 13.B
A ClassCastException is thrown at runtime.C
1 2 3D
Compilation fails because of an error in line 14.E
Compilation fails because of an error in line 12.
考题
单选题1. public class test ( 2. public static void main(string args[]) { 3. int 1= 0; 4. while (i) { 5. if (i==4) { 6. break; 7. } 8. ++i; 9. } 10. 11. } 12. ) What is the value of i at line 10?()A
0B
3C
4D
5E
The code will not compile.
考题
单选题10. public class ClassA { 11. public void methodA() { 12. ClassB classB = new ClassB(); 13. classB.getValue(); 14. } 15. } And: 20. class ClassB { 21. public ClassC classC; 22. 23. public String getValue() { 24. return classC.getValue(); 25. } 26. } And: 30. class ClassC { 31. public String value; 32. 33. public String getValue() { 34. value = “ClassB”; 35. return value; 36. } 37. } Given: ClassA a = new ClassA(); a.methodA(); What is the result?()A
Compilation fails.B
ClassC is displayed.C
The code runs with no output.D
An exception is thrown at runtime.
考题
填空题1. public class test { 2. public static string output = “” 3. 4. public static void foo(int i) { 5. try { 6. if(i= =1) { 7. throw new Exception (); 8. } 9. output += “1”; 10.} 11. catch(Exception e) { 12. output += “2”; 13. return; 14.} 15. finally ( 16. output += “3”; 17. ) 18. output += “4”; 19. } 20. 21. public static void main (string args[]) ( 22. foo(0); 23. foo(1); 24. 25. ) 26. } What is the value of the variable output at line 24?()
考题
单选题在j2ee中,以下是firevetoablechange方法的正确的原型的是()A
public void fireVetoableChange(Object oldValue,Object newValue)B
public void fireVetoableChange(String propertyName,Object newValue)C
public void fireVetoableChange(String propertyName, Object oldValue ,Object newValue)throws PropertyVetoExceptionD
public void fireVetoableChange(String propertyName, Object oldValue ,Object newValue)
考题
多选题11. public interface Status { 12. /* insert code here */ int MY_VALUE = 10; 13. } Which three are valid on line 12?()AfinalBstaticCnativeDpublicEprivateFabstractGprotected
热门标签
最新试卷