单项选择题

 public class Foo { 
 public static void main (String []args) { 
 int i = 1; 
 int j = i++; 
 if ((i>++j) && (i++ ==j))  { 
         i +=j; 
        } 
      } 
    }  
What is the final value of i?()  

A. 1
B. 2
C. 3
D. 4
E. 5


您可能感兴趣的试卷

你可能感兴趣的试题

1.单项选择题

public class X { 
public static void main (String[]args)  { 
String s1 = new String (“true”); 
Boolean b1 = new Boolean (true); 
if (s2.equals(b1))   { 
System.out.printIn(“Equal”); 
} 
} 
}     
What is the result?()  

A. The program runs and prints nothing.
B. The program runs and prints “Equal”
C. An error at line 5 causes compilation to fail.
D. The program runs but aborts with an exception.

2.单项选择题

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.

3.多项选择题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;

4.单项选择题

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.

5.多项选择题

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;

6.单项选择题

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

10.多项选择题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.