多项选择题

AnInterface is an interface.  
AnAdapter0 is a non-abstract, non-final class with a zero argument constructor.  
AnAdapter1 is a non-abstract, non-final class without a zero argument constructor, but with a constructor that  takes one int argument.  
Which two construct an anonymous inner class? ()

A. AnAdapter1 aa=new AnAdapter1(){}
B.AnAdapter0 aa=new AnAdapter0(){}
C. AnAdapter0 aa=new AnAdapter0(5){}
D. AnAdapter1 aa=new AnAdapter1(5){}
E.AnInterface a1=new AnInterface(5){}


您可能感兴趣的试卷

你可能感兴趣的试题

1.单项选择题

class A {  
public byte getNumber () {  
return 1;  
}  
}  
class B extends A {  
public short getNumber() {  
return 2;  
}  
 public static void main (String args) {  
B b = new B ();  
 System.out.printIn(b.getNumber()) 
}  
}  
What is the result?()  

A. Compilation succeeds and 1 is printed.
B. Compilation succeeds and 2 is printed.
C. An error at line 8 causes compilation to fail.
D. An error at line 14 causes compilation to fail.
E. Compilation succeeds but an exception is thrown at line 14.

2.单项选择题Which statement about static inner classes is true?()

A. An anonymous class can be declared as static.
B. A static inner class cannot be a static member of the outer class.
C. A static inner class does not require an instance of the enclosing class.
D. Instance members of a static inner class can be referenced using the class name of the static inner class.

3.多项选择题

class BaseClass{  
private float x= 1.0f;  
protected void setVar (float f) {x = f;}  
}  
class SubClass exyends BaseClass {  
private float x = 2.0f;  
//insert code here  8. }  
Which two are valid examples of method overriding?()

A. Void setVar(float f) {x = f;}
B. Public void setVar(int f) {x = f;}
C. Public void setVar(float f) {x = f;}
D. Public double setVar(float f) {x = f;}
E. Public final void setVar(float f) {x = f;}
F. Protected float setVar() {x=3.0f; return 3.0f; }

4.单项选择题

class A {  
public int getNumber(int a) {  
return a + 1;  
}  
}  
 class B extends A {  
public int getNumber (int a) {  
return a + 2  
}  
 public static void main (String args) {  
A a = new B();  
System.out.printIn(a.getNumber(0));  
}  
}  
What is the result? () 

A. Compilation succeeds and 1 is printed.
B. Compilation succeeds and 2 is printed.
C. An error at line 8 causes compilation to fail.
D. An error at line 13 causes compilation to fail.
E. An error at line 14 causes compilation to fail.

5.单项选择题

import java.awt.*;  
public class Test extends Frame {  
public Test() {  
add(new Label(“Hello”) );  
add(new TextField(“Hello”) );  
add(new Button(“Hello”) );  
pack();  
show();  
 }  
public static void main(String args) {  
new Test ();  
}  
}  
What is the result? () 

A. The code will not compile.
B. A Window will appear containing only a Button.
C. An IllegalArgumentException is thrown at line 6.
D. A Window button will appear but will not contain the Label, TextField, or Button.
E. A Window will appear containing a Label at the top, a TextField below the Label, and a Button  below the TextField.
F. A Window will appear containing a Label on the left, a TextField to the right of the Label, and a button to the right of the TextField.

6.单项选择题Given an ActionEvent, which method allows you to identify the affected Component?()  

A. Public class getClass()
B. Public Object getSource()
C. Public Component getSource()
D. Public Component getTarget()
E. Public Component getComponent()
F. Public Component getTargetComponent()

7.单项选择题Which statement is true?()  

A. A flow layout can be used to position a component that should resize horizontally when the  container is resized.
B. A grid layout can be used to position a component tat should maintain a constant size even when  the container is resized.
C. A border layout can be used to position component that should maintain a constant size even when  the container is resized.
D. The grid bag layout can be used to give a grid-like layout which differs from the normal grid in that individual rows and columns can have unique sizes.
E. If two components are placed in the same column of a grid bag layout, and one component resizes horizontally, then the other component must resize horizontally.

8.单项选择题Which code determines the int value foo closest to, but not greater than, a double value bar?()  

A. Int foo = (int) Math.max(bar);
B. Int foo = (int) Math.min(bar);
C. Int foo = (int) Math.abs(bar);
D. Int foo = (int) Math.ceil(bar);
E. Int foo = (int) Math.floor(bar);
F. Int foo = (int) Math.round(bar);

10.单项选择题Which method in the Thread class is used to create and launch a new thread of execution?()

A. Run();
B. Start();
C. Execute();
D. Run(Runnable r);
E. Start(Runnable r);
F. Execute(Thread t);