多项选择题

Given that Thing is a class, how many objects and reference variables are created by the following code?()  
Thing item, stuff;  
item = new Thing();  
Thing entity = new Thing();

A.One object is created
B.Two objects are created
C.Three objects are created
D.One reference variable is created
E.Two reference variables are created
F.Three reference variables are created.


您可能感兴趣的试卷

你可能感兴趣的试题

2.单项选择题An instance member() 

A.is also called a static member
B.is always a variable
C.is never a method
D.belongs to a single instance, not to the class as a whole
E.always represents an operation

3.单项选择题An object is()

A.what classes are instantiated from.
B.an instance of a class.
C.a blueprint for creating concrete realization of abstractions.
D.a reference to an attribute.
E.a variable.

4.单项选择题A method is()

A.an implementation of an abstraction.
B.an attribute defining the property of a particular abstraction.
C.a category of objects.
D.an operation defining the behavior for a particular abstraction.
E.a blueprint for making operations.

6.多项选择题

public class MethodOver { 
private int x, y; 
private float z; 
public void setVar(int a, int b, float c){ 
x = a; 
y = b; 
z = c; 
} 
}  
Which two overload the setVar method?()   

A.  void setVar (int a, int b, float c){ x = a; y = b; z = c; }
B. public void setVar(int a, float c, int b) { setVar(a, b, c); }
C. public void setVar(int a, float c, int b) { this(a, b, c); }
D. public void setVar(int a, float b){ x = a; z = b; }
E. public void setVar(int ax, int by, float cz) { x = ax; y = by; z = cz; }

8.多项选择题Which two demonstrate encapsulation of data?()  

A. Member data have no access modifiers.
B. Member data can be modified directly.
C. The access modifier for methods is protected.
D. The access modifier to member data is private.
E. Methods provide for access and modification of data.

9.单项选择题

public class Test { 
public static void main (String [] args)  { 
string foo = “blue”; 
string bar = foo; 
foo = “green”; 
System.out.printIn(bar); 
} 
}  
What is the result?()  

A. An exception is thrown.
B. The code will not compile.
C. The program prints “null”
D. The program prints “blue”
E. The program prints “green”

10.单项选择题

2. public class Foo implements Runnable ( 
3. public void run (Thread t) { 
4. system.out.printIn(“Running.”); 
5. } 
6. public static void main (String[] args)  { 
7. new thread (new Foo()).start();
8. ) 
9. )  
What is the result?()      

A. An exception is thrown.
B. The program exists without printing anything.
C. An error at line 1 causes compilation to fail.
D. An error at line 6 causes the compilation to fail.
E. “Running” is printed and the program exits.