会计考友 发表于 2012-8-4 12:33:16

2011年JAVA认证模拟题第二阶段(27)

  Q79.What is the result of attempting to compile the following program
  1. public class Test {
  2. public void method(StringBuffer sb) {
  3. System.out.println(“StringBuffer Verion”);
  4. }
  5. public void method(String s) {
  6. System.out.println(“String Version”);
  7. }
  8. public static void main(String args[]) {
  9. Test test = new Test();
  10. test.method(null);
  11. }
  12. }
  Select one correct answer
  a. The code does not compile.
  b. The code compiles correctly and shows
  c. The code compiles correctly and shows “String Version”.
  d. The code throws an Exception at Runtime. NullPointerException in the 2nd line of the main method.
  Q80.What is the requirement of the class which implements the following Interface
  1. public interface Test {
  2. void someMethod();
  3. }
  Select all correct answers
  a. Should have someMethod which must be necessarily declared as public.
  b. Should have someMethod which could be “friendly” or public
  c. Should have someMethod which should not throw any checked exceptions.
  d. Should have someMethod which cannot be sychronized as sychronized is not in the signature of the interface definition.
  Q81.What is the result of attempting to compile and run the following program?
  1. public class AStringQuestion {
  2. static String s1;
  3. static String s2;
  4. public static void main(String args[]) {
  5. s2 = s1+s2;
  6. System.out.println(s2);
  7. }
  8. }
  
  a. Will cause a compilation error. “StringBuffer Version”.
  b. Runtime Execption -
  c. Will compile successfully and print “nullnull” on the screen.
  d. Will compile successfully and print an empty line on the screen.
  79. a
  80. ac
  81. c
页: [1]
查看完整版本: 2011年JAVA认证模拟题第二阶段(27)