Compilation will fail.
Compilation will succeed and the program will print “3”
Compilation will succeed but the program will throw a ClassCastException at line 6.
Compilation will succeed but the program will throw a ClassCastException at line 7.
第1题:
public class Test { public static void main (String args) { class Foo { public int i = 3; } Object o = (Object) new Foo(); Foo foo = (Foo)o; System.out.printIn(foo. i); } } What is the result?()
第2题:
public class Delta { static boolean foo(char c) { System.out.print(c); return true; } public static void main( String[] argv ) { int i =0; for ( foo(‘A’); foo(‘B’)&&(i<2); foo(‘C’)){ i++ ; foo(‘D’); } } } What is the result?()
第3题:
public class Test { public static void main(String args[]) { class Foo { public int i = 3; } Object o = (Object)new Foo(); Foo foo = (Foo)o; System.out.println(“i = “ + foo.i); } } What is the result?()
第4题:
2. public class Foo implements Runnable ( 3. public void run (Thread t) { 4. system.out.printIn(“Running.”); 5. } 6. public static void main (String[] args) { 7. new thread (new Foo()).start(); 8. ) 9. ) What is the result?()
第5题:
package foo; import java.util.Vector; private class MyVector extends Vector { int i = 1; public MyVector() { i = 2; } } public class MyNewVector extends MyVector { public MyNewVector () { i = 4; } public static void main (String args ) { MyVector v = new MyNewVector(); } } The file MyNewVector.java is shown in the exhibit. What is the result?()
第6题:
interface foo { int k = 0; } public class test implements Foo ( public static void main(String args) ( int i; Test test = new test (); i= test.k; i= Test.k; i= Foo.k; ) ) What is the result? ()
第7题:
Compilation succeeds.
An error at line 2 causes compilation to fail.
An error at line 9 causes compilation to fail.
An error at line 10 causes compilation to fail.
An error at line 11 causes compilation to fail.
第8题:
ABDCBDCB
ABCDABCD
Compilation fails.
An exception is thrown at runtime.
第9题:
An exception is thrown.
The program exists without printing anything.
An error at line 1 causes compilation to fail.
An error at line 6 causes the compilation to fail.
“Running” is printed and the program exits.
第10题:
Baz has the value of “”
Baz has the value of null
Baz has the value of “red”
Baz has the value of “blue”
Bax has the value of “green”
The program throws an exception.
第11题:
Compilation will fail.
Compilation will succeed and the program will print “3”
Compilation will succeed but the program will throw a ClassCastException at line 6.
Compilation will succeed but the program will throw a ClassCastException at line 7.
第12题:
foofoofoofoofoo
foobarfoobarbar
foobarfoofoofoo
foobarfoobarfoo
barbarbarbarbar
foofoofoobarbar
foofoofoobarfoo
第13题:
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 23?()
第14题:
1. interface foo { 2. int k = 0; 3. } 4. 5. public class test implements Foo ( 6. public static void main(String args[]) ( 7. int i; 8. Test test = new test (); 9. i= test.k; 10.i= Test.k; 11.i= Foo.k; 12.) 13.) 14. What is the result?()
第15题:
public class Foo { private int val; public foo(int v) (val = v;) } public static void main (String [] args) { Foo a = new Foo (10); Foo b = new Foo (10); Foo c = a; int d = 10; double e = 10.0; } Which three logical expression evaluate to true?()
第16题:
public class test( public static void main(stringargs){ string foo = args [1]; string foo = args ; string foo = args ; } ) And command line invocation: Java Test red green blue What is the result? ()
第17题:
1.public class Test { 2.public static void main (String args[]) { 3.class Foo { 4.public int i = 3; 5.} 6.Object o = (Object) new Foo(); 7.Foo foo = (Foo)o; 8.System.out.printIn(foo. i); 9. } 10.} What is the result?()
第18题:
Compilation will fail.
Compilation will succeed and the program will print “3”
Compilation will succeed but the program will throw a ClassCastException at line 6.
Compilation will succeed but the program will throw a ClassCastException at line 7.
第19题:
Baz has the value of “”
Baz has the value of null
Baz has the value of “red”
Baz has the value of “blue”
Bax has the value of “green”
The program throws an exception.
第20题:
i = 3
Compilation fails.
A ClassCastException is thrown at line 6.
A ClassCastException is thrown at line 7.
第21题:
An exception is thrown.
The program exists without printing anything.
An error at line 1 causes compilation to fail.
An error at line 6 causes the compilation to fail.
“Running” is printed and the program exits.
第22题:
An exception is thrown.
The code will not compile.
The program prints “null”
The program prints “blue”
The program prints “green”
第23题:
Compilation will succeed.
Compilation will fail at line 5.
Compilation will fail at line 6.
Compilation will fail at line 14.
Compilation will fail at line 17.
第24题:
Compilation succeeds.
An error at line 2 causes compilation to fail.
An error at line 9 causes compilation to fail.
An error at line 10 causes compilation to fail.
An error at line 11 causes compilation to fail.