10. public class ClassA { 11. public void count(int i) { 12. count(++i); 13. } 14. } And: 20. ClassA a = new ClassA(); 21. a.count(3); Which exception or error should be thrown by the virtual machine?()
第1题:
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?()
第2题:
Just after line 5.
Just after line 6.
Just after line 7.
Just after line 8(that is, as the method returns).
第3题:
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.
第4题:
new Inner(); // At line 3
new Inner(); // At line 8
new o.Inner(); // At line 8
new Outer.Inner(); // At line 8
第5题:
Point p = Line.getPoint();
Line.Point p = Line.getPoint();
Point p = (new Line()).getPoint();
Line.Point p = (new Line()).getPoint();
第6题:
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.
第7题:
StackOverflowError
NullPointerException
NumberFormatException
IllegalArgumentException
ExceptionlnlnitializerError
第8题:
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
第9题:
Direction d = NORTH;
Nav.Direction d = NORTH;
Direction d = Direction.NORTH;
Nav.Direction d = Nav.Direction.NORTH;
第10题:
Compilation fails.
Cannot add Toppings
The code runs with no output.
A NullPointerException is thrown in Line 4.
第11题:
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?()
第12题:
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
第13题:
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; } }
第14题:
Value is: 8
Compilation fails.
Value is: 12
Value is: -12
The code runs with no output.
An exception is thrown at runtime.
第15题:
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.
第16题:
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.
第17题:
0
3
4
5
The code will not compile.
第18题:
Compilation fails.
ClassC is displayed.
The code runs with no output.
An exception is thrown at runtime.
第19题:
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.