多项选择题

1. public class OuterClass { 
2. private double d1 = 1.0; 
3. // insert code here 
4. } 
Which two are valid if inserted at line 3?()  

A. static class InnerOne { public double methoda() { return d1; } }
B. static class InnerOne { static double methoda() { return d1; } }
C. private class InnerOne { public double methoda() { return d1; } }
D. protected class InnerOne { static double methoda() { return d1; } }
E. public abstract class InnerOne { public abstract double methoda(); }


您可能感兴趣的试卷

你可能感兴趣的试题

2.单项选择题

public class Test { 
public static void main(String[] args) { 
int x = 0; 
assert (x > 0) ? “assertion failed” : “assertion passed”; 
System.out.println(“Finished”); 
} 
} 
What is the result?()  

A. finished
B. Compilation fails.
C. An AssertionError is thrown and finished is output.
D. An AssertionError is thrown with the message “assertion failed”.
E. An AssertionError is thrown with the message “assertion passed”.

8.单项选择题

public void test(int x) { 
int odd = x%2; 
if (odd) { 
 System.out.println(“odd); 
} else { 
System.out.println(“even”); 
} 
} 
Which statement is true?() 

A.Compilation fails.
B. “odd” will always be output.
C. “even” will always be output.
D. “odd” will be output for odd values of x, and “even” for even values.
E. “even” will be output for add values of x, and “odd” for even values.

10.多项选择题Which three statements are true?()

A. The default constructor initializes method variables.
B. The default constructor has the same access as its class.
C. The default constructor invoked the no-arg constructor of the superclass.
D. If a class lacks a no-arg constructor, the compiler always creates a default constructor. 
E. The compiler creates a default constructor only when there are no other constructors for the class.