black

SCJP程序员认证考试

登录

单项选择题

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.

相关考题

单项选择题 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?()

单项选择题 static void test() throws RuntimeException {  try {  System.out.print(”test “);  throw new RuntimeException();  }  catch (Exception ex) { System.out.print(”exception “); }  }  public static void main(String[] args) {  try { test(); }  catch (RuntimeException ex) { System.out.print(”runtime “); }  System.out.print(”end “);  }  What is the result?()

单项选择题 static void test() {  try {  String x=null;  System.out.print(x.toString() +“ “);  }  finally { System.out.print(“finally “); }  }  public static void main(String[] args) {  try { test(); }  catch (Exception ex) { System.out.print(”exception “); }  }  What is the result?()

All Rights Reserved 版权所有©考试题库网(kstiku.com)

备案号:湘ICP备14005140号-3

经营许可证号:湘B2-20140064