2011年JAVA认证模拟题第二阶段(29)
Q85.What is the result of attempting to compile and run the following program?1. public class Test {
2. private int i = j;
3. private int j = 10;
4.
5. public static void main(String args[]) {
6. System.out.println((new Test()).i);
7. }
8. }
a. Compiler error complaining about access restriction of private variables of Test.
b. Compiler error complaining about forward referencing.
c. No error - The output is 0;
d. No error - The output is 10;
Q86.What is the result of attempting to compile and run the following program
1. public class A {
2. private void method1() throws Exception {
3. throw new RuntimeException();
4. }
6. public void method2() {
7. try {
8. method1();
9. } catch(RuntimeException e) {
10. System.out.println(“Caught Runtime Exception”);
11. } catch(Exception e) {
12. System.out.println(“Caught Exception”);
13. }
14. }
2011年JAVA认证模拟题第二阶段(29)
</p> 15. public static void main(String args[]) {16. A a = new A();
17. a.method2();
18. }
19. }
a. It will not compile.
b. It will compile and show - “Caught Exception”.
c. It will compile and show - “Caught Runtime Exception”.
d. It will compile and show both the messages one after another in the order they appear.
Q87.Assume that Cat is a class and String[] args is the argument passed to the public static void main(String args[]) method of the class. The class is executed with the following command line string c;\somedirectory> java Cat An expression in the main method is as follows 1. System.out.println(args.length);What is the result of attempting to compile and run the snipped.
a. The above expression will cause a '0' appear on the command line.
b. It will throw a N ullPointerException.
c. It will cause a nk line to appear.
d. It will cause a comilation error at line 1 due to length.
85. b
86. c
87. a
页:
[1]