10. public class Bar { 11.static void foo(int...x) { 12. // insert code here 13. } 14. } Which two code fragments, inserted independently at line 12, will allow the class to compile?()
第1题:
1. public class A { 2. public void doit() { 3. } 4. public String doit() { 5. return “a”; 6. } 7. public double doit(int x) { 8. return 1.0; 9. } 10.} What is the result?()
第2题:
1. public class X { 2. public object m () { 3. object o = new float (3.14F); 4. object [] oa = new object [1]; 5. oa[0]= o; 6. o = null; 7. oa[0] = null; 10. return o; 9. } 10. } When is the float object created in line 3, eligible for garbage collection?()
第3题:
Cat is-a Jumper
Cat is-a Animal
Dog is-a Jumper
Dog is-a Animal
Beagle has-a Jumper
Cat has-a Animal
Beagle has-a Tail
第4题:
Foo { public int bar() { return 1; } }
new Foo { public int bar() { return 1; } }
newFoo() { public int bar(){return 1; } }
new class Foo { public int bar() { return 1; } }
第5题:
Value is: 8
Compilation fails.
Value is: 12
Value is: -12
The code runs with no output.
An exception is thrown at runtime.
第6题:
Compilation fails because of an error in line 3.
Compilation fails because of an error in line 7.
Compilation fails because of an error in line 9.
If you define D e = new E(), then e.bMethod() invokes the version of bMethod()defined in Line 5.
If you define D e = (D)(new E()),then e.bMethod() invokes the version of bMethod() defined in Line 5.
If you define D e = (D)(new E()), then e.bMethod() invokes the version of bMethod() defined in Line 9.
第7题:
The program runs and prints “0”
The program runs and prints “1”
The program runs but aborts with an exception.
An error “possible undefined variable” at line 4 causes compilation to fail.
An error “possible undefined variable” at line 9 causes compilation to fail.
第8题:
0
3
4
5
The code will not compile.
第9题:
Compilation fails.
ClassC is displayed.
The code runs with no output.
An exception is thrown at runtime.
第10题:
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.
第11题:
1. public class X { 2. public static void main (String[]args) { 3. int [] a = new int [1] 4. modify(a); 5. System.out.printIn(a[0]); 6. } 7. 8. public static void modify (int[] a) { 9. a[0] ++; 10. } 11. } What is the result?()
第12题:
Just after line 5.
Just after line 6.
Just after line 7.
Just after line 8(that is, as the method returns).
第13题:
An exception is thrown at runtime.
Compilation fails because of an error in line 7.
Compilation fails because of an error in line 4.
Compilation succeeds and no runtime errors with class A occur.
第14题:
new Inner(); // At line 3
new Inner(); // At line 8
new o.Inner(); // At line 8
new Outer.Inner(); // At line 8
第15题:
Point p = Line.getPoint();
Line.Point p = Line.getPoint();
Point p = (new Line()).getPoint();
Line.Point p = (new Line()).getPoint();
第16题:
Compilation will succeed if a extends b.
Compilation will succeed if b extends a.
Compilation will always fail because of an error in line 7.
Compilation will always fail because of an error in line 8.
第17题:
StackOverflowError
NullPointerException
NumberFormatException
IllegalArgumentException
ExceptionlnlnitializerError
第18题:
Cat is-a Animal
Cat is-a Jumper
Dog is-a Animal
Dog is-a Jumper
Cat has-a Animal
Beagle has-a Tail
Beagle has-a Jumper
第19题:
Direction d = NORTH;
Nav.Direction d = NORTH;
Direction d = Direction.NORTH;
Nav.Direction d = Nav.Direction.NORTH;
第20题:
Compilation fails.
Cannot add Toppings
The code runs with no output.
A NullPointerException is thrown in Line 4.