Compilation succeeds and 1 is printed.
Compilation succeeds and 2 is printed.
An error at line 8 causes compilation to fail.
An error at line 13 causes compilation to fail.
An error at line 14 causes compilation to fail.
第1题:
在下列源代码文件Test.java中,哪个选项是正确的类定义? ( )
A.public class test { public int x=0; public test(int x) { this.x=x; } }
B.public class Test { public int x=0; public Test(int x) { this.x=x; } }
C.public class Test extends Ti,T2 { public int x=0; public Test(int x) { this.x=x; } }
D.protected class Test extends T2 { public int x=0; public Test(int x) { this.x=x; } }
第2题:
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?()
第3题:
现有: 1. class Synapse { 2. protected int gap() { return 7; } 3. } 4. 5. class Creb extends Synapse { 6. // insert code here 7. } 分别插入到第 6 行,哪三行可以编译?()
第4题:
Given: 1. public class ConstOver { 2. public constOver(int x, int y, int z) { 3. } 4. } Which two overload the ConstOver Constructor?()
第5题:
1. public class Test { 2. int x= 12; 3. public void method(int x) { 4. x+=x; 5. System.out.println(x); 6. } 7. } Given: 34. Test t = new Test(); 35. t.method(5); What is the output from line 5 of the Test class?()
第6题:
1. public class A { 2. public String doit(int x, int y) { 3. return “a”; 4. } 5. 6. public String doit(int... vals) { 7. return “b”; 8. } 9. } Given: 25. A a=new A(); 26. System.out.println(a.doit(4, 5)); What is the result?()
第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题:
5
10
12
17
24
第9题:
public class Circle implements Shape { private int radius; }
public abstract class Circle extends Shape { private int radius; }
public class Circle extends Shape { private int radius; public void draw(); }
public abstract class Circle implements Shape { private int radius; public void draw(); }
public class Circle extends Shape { private int radius;public void draw() {/* code here */} }
public abstract class Circle implements Shape { private int radius;public void draw() { / code here */ } }
第10题:
final int k = 4:
public int k = 4:
static int k = 4:
private int k = 4:
abstract int k = 4:
volatile int k = 4:
transient int k = 4:
protected int k = 4:
第11题:
Compilation succeeds and 1 is printed.
Compilation succeeds and 2 is printed.
An error at line 8 causes compilation to fail.
An error at line 13 causes compilation to fail.
An error at line 14 causes compilation to fail.
第12题:
public int blipvert(int x) { return 0; }
private int blipvert(int x) { return 0; }
private int blipvert(long x) { return 0; }
protected long blipvert(int x, int y) { return 0; }
protected int blipvert(long x) { return 0; }
protected long blipvert(long x) { return 0; }
protected long blipvert(int x) { return 0; }
第13题:
1. public class Target { 2. private int i = 0; 3. public int addOne() { 4. return ++i; 5. } 6. } And: 1. public class Client { 2. public static void main(String[] args) { 3. System.out.println(new Target().addOne()); 4. } 5. } Which change can you make to Target without affecting Client?()
第14题:
Given: 1. public class Method Over { 2. public void set Var (int a, int b, float c) { 3. } 4. } Which two overload the set Var method()?
第15题:
Given: 1. public interface Foo { 2. int k = 4: 3. } Which three are equivalent to line 2?()
第16题:
public class Parent { public int addValue( int a, int b) { int s; s = a+b; return s; } } class Child extends Parent { } Which methods can be added into class Child?()
第17题:
public class Parent { int change() {…} } class Child extends Parent { } Which methods can be added into class Child?()
第18题:
public abstract class Shape { private int x; private int y; public abstract void draw(); public void setAnchor(int x, int y) { this.x = x; this.y = y; } } Which two classes use the Shape class correctly?()
第19题:
Line 26 prints “a” to System.out.
Line 26 prints „b” to System.out.
An exception is thrown at line 26 at runtime.
Compilation of class A will fail due to an error in line 6.
第20题:
private void set Var(int a, float c, int b) {}
protected void set Var(int a, int b, float c) {}
public int set Var(int a, float c, int b) {return a:}
public int set Var(int a, int b, float c) {return a:}
protected float set Var(int a, int b, float c) {return c:}
第21题:
Value is: 8
Compilation fails.
Value is: 12
Value is: -12
The code runs with no output.
An exception is thrown at runtime.
第22题:
ConstOver() {}
protected int ConstOver(){}
private ConstOver(int z, int y, byte x ) {}
public Object ConstOver(Int x, int y, int z) {}
pubic void ConstOver (byte x, byte y, byte z) {}
第23题:
Change line 2 to: public int a;
Change line 2 to: protected int a;
Change line 13 to: public Sub() { this(5); }
Change line 13 to: public Sub() { super(5); }
Change line 13 to: public Sub() { super(a); }