Which statements can be inserted at the indicated position in the following code to make the program write 1 on the standard output when run?() public class Q4a39 { int a = 1; int b = 1; int c = 1; class Inner { int a = 2; int get() { int c = 3; // insert statement here return c; } } Q4a39() { Inner i = new Inner(); System.out.println(i.get()); } public static void main(String args[]) { new Q4a39(); } }
第1题:
Which lines of code are valid declarations of a native method when occurring within the declaration of the following class?() public class Qf575 { // insert declaration of a native method here }
第2题:
Which line contains a constructor in this class definition?() public class Counter { // (1) int current, step; public Counter(int startValue, int stepValue) { // (2) set(startValue); setStepValue(stepValue); } public int get() { return current; } // (3) public void set(int value) { current = value; } // (4) public void setStepValue(int stepValue) { step = stepValue; } // (5) }
第3题:
10. interface Foo { int bar(); } 11. public class Sprite { 12. public int fubar( Foo foo) { return foo.bar(); } 13. public void testFoo() { 14. fubar( 15. // insert code here 16.); 17. } 18. } Which code, inserted at line 15, allows the class Sprite to compile?()
第4题:
Given the following class, which statements can be inserted at position 1 without causing the code to fail compilation?() public class Q6db8 { int a; int b = 0; static int c; public void m() { int d; int e = 0; // Position 1 } }
第5题:
public class Score implements Comparable
第6题:
Given the following code: public class Person{ int arr[] = new int[10]; public static void main(String a[]) { System.out.println(arr[1]); } } Which statement is correct?()
第7题:
1. public class Blip { 2. protected int blipvert(int x) { return 0; } 3. } 4. class Vert extends Blip { 5. // insert code here 6. } Which five methods, inserted independently at line 5, will compile?()
第8题:
native public void setTemperature(int kelvin);
private native void setTemperature(int kelvin);
protected int native getTemperature();
public abstract native void setTemperature(int kelvin);
native int setTemperature(int kelvin) {}
第9题:
a++;
b++;
c++;
d++;
e++;
第10题:
c = b;
c = this.a;
c = this.b;
c = Q4a39.this.a;
c = c;
第11题:
Code marked with (1) is a constructor
Code marked with (2) is a constructor
Code marked with (3) is a constructor
Code marked with (4) is a constructor
Code marked with (5) is a Constructor
第12题:
The program will fail to compile.
The program will not terminate normally.
The program will write 10 to the standard output.
The program will write 0 to the standard output.
The program will write 9 to the standard output.
第13题:
What will be the result of attempting to compile and run the following code?() public class Q6b0c { public static void main(String args[]) { int i = 4; float f = 4.3; double d = 1.8; int c = 0; if (i == f) c++; if (((int) (f + d)) == ((int) f + (int) d)) c += 2; System.out.println(c); } }
第14题:
Given the following code, which method declarations, when inserted at the indicated position, will not cause the program to fail compilation?() public class Qdd1f { public long sum(long a, long b) { return a + b; } // insert new method declaration here }
第15题:
What will be written to the standard output when the following program is run?() public class Q8499 { public static void main(String args[]) { double d = -2.9; int i = (int) d; i *= (int) Math.ceil(d); i *= (int) Math.abs(d); System.out.println(i); } }
第16题:
What will be written to the standard output when the following program is run?() class Base { int i; Base() { add(1); } void add(int v) { i += v; } void print() { System.out.println(i); } } class Extension extends Base { Extension() { add(2); } void add(int v) { i += v*2; } } public class Qd073 { public static void main(String args[]) { bogo(new Extension()); } static void bogo(Base b) { b.add(8); b.print(); } }
第17题:
What will be the result of attempting to compile and run the following program?() public class Q28fd { public static void main(String args[]) { int counter = 0; l1: for (int i=10; i<0; i--) { l2: int j = 0; while (j < 10) { if (j > i) break l2; if (i == j) { counter++; continue l1; } } counter--; } System.out.println(counter); } }
第18题:
public class Parent { int change() {…} } class Child extends Parent { } Which methods can be added into class Child?()
第19题:
What will be written to the standard output when the following program is run?() public class Qcb90 { int a; int b; public void f() { a = 0; b = 0; int[] c = { 0 }; g(b, c); System.out.println(a + " " + b + " " + c[0] + " "); } public void g(int b, int[] c) { a = 1; b = 1; c[0] = 1; } public static void main(String args[]) { Qcb90 obj = new Qcb90(); obj.f(); } }
第20题:
public int sum(int a, int b) { return a + b; }
public int sum(long a, long b) { return 0; }
abstract int sum();
private long sum(long a, long b) { return a + b; }
public long sum(long a, int b) { return a + b; }
第21题:
The code will fail to compile.
0 will be written to the standard output.
1 will be written to the standard output.
2 will be written to the standard output.
3 will be written to the standard output.
第22题:
When compilation some error will occur.
It is correct when compilation but will cause error when running.
The output is zero.
The output is null.
第23题:
When compilation some error will occur.
It is correct when compilation but will cause error when running.
The output is zero.
The output is null.