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题:
class One { public One foo() { return this; } } class Two extends One { public One foo() { return this; } } class Three extends Two { // insert method here } Which two methods, inserted individually, correctly complete the Three class?()
第3题:
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?()
第4题:
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?()
第5题:
public class Foo { public static void main(String[] args) { try { return; } finally { System.out.println( “Finally” ); } } } What is the result?()
第6题:
public class Foo { public int a; public Foo() { a = 3; } public void addFive() { a += 5; } } and: public class Bar extends Foo { public int a; public Bar() { a = 8; } public void addFive() { this.a +=5; } } invoked with: Foo foo = new Bar(); foo.addFive(); System.out.println(”Value: “+ foo.a); What is the result?()
第7题:
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.
第8题:
Value: 3
Value: 8
Value: 13
Compilation fails.
The code runs with no output.
An exception is thrown at runtime.
第9题:
i = 3
Compilation fails.
A ClassCastException is thrown at line 6.
A ClassCastException is thrown at line 7.
第10题:
Compilation will fail.
Compilation will succeed and the program will print “0”
Compilation will succeed and the program will print “1”
Compilation will succeed and the program will print “2”
第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题:
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(); } } What is the result?()
第14题:
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?()
第15题:
public class test( public int aMethod()[ static int i=0; i++; return I; ) public static void main (String args){ test test = new test(); test.aMethod(); int j = test.aMethod(); System.out.printIn(j); ] } What is the result?()
第16题:
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?()
第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题:
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? ()
第19题:
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.
第20题:
ABDCBDCB
ABCDABCD
Compilation fails.
An exception is thrown at runtime.
第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.