单项选择题

String foo = “blue”; 
Boolean[]bar = new Boolean [1]; 
if (bar[0])  { 
foo = “green”; 
}  
What is the result? () 

A. Foo has the value of “”
B. Foo has the value of null.
C. Foo has the value of “blue”
D. Foo has the value of “green”
E. An exception is thrown.
F. The code will not compile.


您可能感兴趣的试卷

你可能感兴趣的试题

1.多项选择题Which two valid declarations of a char?()   

A. Char ch = “a”;
B. Char ch = ‘\’ ‘;
C. Char ch = ‘cafe’;
D. Char ch = “cafe”;
E. Char ch = ‘\ucafe’;
F. Char ch = ‘\u10100’;
G. Char ch = (char) true;

2.单项选择题

public class foo { 
static String s; 
public static void main (String[]args) { 
system.out.printIn (“s=” + s); 
}
} 
What is the result?()  

A. The code compiles and “s=” is printed.
B. The code compiles and “s=null” is printed.
C. The code does not compile because string s is not initialized.
D. The code does not compile because string s cannot be referenced.
E. The code compiles, but a NullPointerException is thrown when toString is called.

3.多项选择题

public interface Foo{ 
int k = 4; 
}  
Which three are equivalent to line 2?() 

A. Final int k = 4;
B. Public int k = 4;
C. Static int k = 4;
D. Private int k = 4;
E. Abstract int k = 4;
F. Volatile int k = 4;

4.单项选择题

int index = 1; 
String [] test = new String[3]; 
String foo = test[index];    
What is the result?()  

A. Foo has the value “”
B. Foo has the value null
C. An exception is thrown
D. The code will not compile

8.多项选择题Which two statements are true regarding the creation of a default constructor?() 

A. The default constructor initializes method variables.
B. The compiler always creates a default constructor for every class.
C. The default constructor invokes the no-parameter constructor of the superclass.
D. The default constructor initializes the instance variables declared in the class.
E. When a class has only constructors with parameters, the compiler does not create a default constructor.

9.单项选择题

1. public class ArrayTest { 
2. public static void main (String[]args)  { 
3. float f1[], f2[]; 
4. f1 = new float [10]; 
5. f2 = f1; 
6. System.out.printIn (“f2[0]=” + f2[0]); 
7.  } 
8. }  
What is the result?()  

A. It prints f2[0] = 0.0
B. It prints f2[0] = NaN
C. An error at line 5 causes compile to fail.
D. An error at line 6 causes compile to fail.
E. An error at line 6 causes an exception at runtime.

最新试题

Given:  foo and bar are public references available to many other threads, foo refers to a Thread and bar is an Object. The thread foo is currently executing bar.wait().  From another thread, what provides the most reliable way to ensure that foo will stop executing wait()?()

题型:单项选择题

What is the result?()

题型:单项选择题

A programmer must create a generic class MinMax and the type parameter of MinMax must implement Comparable. Which implementation of MinMax will compile?()

题型:单项选择题

A programmer is developing a class Key, that will be used as a key in a standard java.util.HashMap.  Which two methods should be overridden to assure that Key works correctly as a key?()

题型:多项选择题

What is the result?()

题型:单项选择题

What is the result?()

题型:单项选择题

Given that Triangle implements Runnable, and:Which two statements, inserted independently at both lines 35 and 41, tend to allow both threads to temporarily pause and allow the other thread to execute?()

题型:多项选择题

What is the result?()

题型:单项选择题

What is the result?()

题型:单项选择题

Which statement is true?()

题型:单项选择题