单项选择题

public class Bootchy { 
int bootch; 
String snootch; 
public Bootchy() { 
this(”snootchy”); 
System.out.print(”first “); 
} 
public Bootchy(String snootch) { 
this(420, “snootchy”); 
System.out.print(”second “); 
} 
public Bootchy(int bootch, String snootch) { 
this.bootch = bootch; 
this.snootch = snootch; 
System.out.print(”third “); 
} 
public static void main(String[] args) { 
Bootchy b = new Bootchy(); 
System.out.print(b.snootch +“ “ + b.bootch); 
} 
} 
What is the result?() 

A. snootchy 420 third second first
B. snootchy 420 first second third
C. first second third snootchy 420
D. third second first siiootchy 420
E. third first second snootchy 420
F. first second first third snootchy 420


您可能感兴趣的试卷

你可能感兴趣的试题

1.单项选择题

public class Plant { 
private String name; 
public Plant(String name) { this.name = name; } 
public String getName() { return name; } 
} 
public class Tree extends Plant { 
public void growFruit() { } 
public void dropLeaves() { } 
} 
Which is true?() 

A. The code will compile without changes.
B. The code will compile if public Tree() { Plant(); } is added to the Tree class.
C. The code will compile if public Plant() { Tree(); } is added to the Plant class.
D. The code will compile if public Plant() { this(”fern”); } is added to the Plant class.
E. The code will compile if public Plant() { Plant(”fern”); } is added to the Plant class.

5.单项选择题

10. class Line { 
11. public static class Point { } 
12. } 
13. 
14. class Triangle { 
15. // insert code here 
16. } 
Which code, inserted at line 15, creates an instance of the Point class defined in Line?() 

A. Point p = new Point();
B. Line.Point p = new Line.Point();
C. The Point class cannot be instatiated at line 15.
D. Line 1 = new Line() ; 1.Point p = new 1.Point();

6.单项选择题

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?() 

A. An exception is thrown at runtime.
B. Compilation fails because of an error in line 7.
C. Compilation fails because of an error in line 4.
D. Compilation succeeds and no runtime errors with class A occur.

7.单项选择题

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?() 

A. Line 26 prints “a” to System.out.
B. Line 26 prints „b” to System.out.
C. An exception is thrown at line 26 at runtime.
D. Compilation of class A will fail due to an error in line 6.

9.多项选择题

class One { 
void foo() {} 
} 
class Two extends One { 
 //insert method here 
} 
Which three methods, inserted individually at line 14, will correctly complete class Two?()

A. int foo() { /* more code here */ }
B. void foo() { /* more code here */ }
C. public void foo() { /* more code here */ }
D. private void foo() { /* more code here */ }
E. protected void foo() { /* more code here */ }

10.多项选择题

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?()

A. public void foo() { }
B. public int foo() { return 3; }
C. public Two foo() { return this; }
D. public One foo() { return this; }
E. public Object foo() { return this; }