多项选择题

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 */ }


您可能感兴趣的试卷

你可能感兴趣的试题

1.多项选择题

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; }

2.多项选择题

A JavaBeans component has the following field: 
11. private boolean enabled; 
Which two pairs of method declarations follow the JavaBeans standard for accessing this field?()

A. public void setEnabled( boolean enabled) public boolean getEnabled()
B. public void setEnabled( boolean enabled) public void isEnabled()
C. public void setEnabled( boolean enabled) public boolean isEnabled()
D. public boolean setEnabled( boolean enabled) public boolean getEnabled()

6.多项选择题

10. class Foo { 
11. static void alpha() { /* more code here */ } 
12. void beta() { /* more code here */ } 
13. } 
Which two are true?()

A. Foo.beta() is a valid invocation of beta().
B. Foo.alpha() is a valid invocation of alpha().
C. Method beta() can directly call method alpha().
D. Method alpha() can directly call method beta().

7.单项选择题

11. public static void main(String[] args) { 
12. Object obj =new int[] { 1,2,3 }; 
13. int[] someArray = (int[])obj; 
14. for (int i: someArray) System.out.print(i +“ “) 
15. } 
What is the result? ()

A. 1 2 3
B. Compilation fails because of an error in line 12.
C. Compilation fails because of an error in line 13.
D. Compilation fails because of an error in line 14.
E. A ClassCastException is thrown at runtime.

9.单项选择题

public class Ball { 
public enum Color { RED, GREEN, BLUE }; 
public void foo() { 
// insert code here 
{ System.out.println(c); } 
} 
} 
Which code inserted at line 14 causes the foo method to print RED, GREEN, and BLUE?() 

A. for( Color c : Color.values())
B. for( Color c = RED; c <= BLUE; c++)
C. for( Color c; c.hasNext() ; c.next())
D. for( Color c = Color[0]; c <= Color[2]; c++)
E. for( Color c = Color.RED; c <= Color.BLUE; c++)

10.多项选择题Which two code fragments correctly create and initialize a static array of int elements?() 

A. static final int[] a = { 100,200 };
B. static final int[] a; static { a=new int[2]; a[0]=100; a[1]=200; }
C. static final int[] a = new int[2] { 100,200 };
D. static final int[] a; static void init() { a = new int[3]; a[0]=100; a[1]=200; }