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(); }
您可能感兴趣的试卷
你可能感兴趣的试题
1. public class ReturnIt {
2. return Type methodA(byte x, double y) {
3. return (long)x / y * 2;
4. }
5. }
What is the narrowest valid returnType for methodA in line2?()
A. int
B. byte
C. long
D. short
E. float
F. double
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”.
public class X {
public static void main(String [] args) {
try {
badMethod();
System.out.print(“A”);
}
catch (RuntimeException ex) {
System.out.print(“B”);
}
catch (Exception ex1) {
System.out.print(“C”);
}
finally {
System.out.print(“D”);
}
System.out.print(“E”);
}
public static void badMethod() {
throw new RuntimeException();
}
}
What is the result?()
A. BD
B. BCD
C. BDE
D. BCDE
E. ABCDE
F. Compilation fails.
switch(x) {
default:
System.out.println(“Hello”);
}
Which two are acceptable types for x?()
A. byte
B. long
C. char
D. float
E. Short
F. Long
A. public
B. private
C. protected
D. transient
E. default access
public class Test {
public static void main(String[] args) {
int x = 0;
assert (x > 0): “assertion failed”;
System.out.println(“finished”);
}
}
What is the result?()
A. finished
B. Compilation fails.
C. An AssertionError is thrown.
D. An AssertionError is thrown and finished is output.
A. 4,4
B. 4,5
C. 5,4
D. 5,5
E. Compilation fails.
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.
class Super {
public int getLenght() { return 4; }
}
public class Sub extends Super {
public long getLenght() { return 5; }
public static void main(String[] args) {
Super sooper = new Super();
Sub sub = new Sub();
System.out.println(
sooper.getLenght() + “,” + sub.getLenght() );
}
}
What is the output?()
A. Just after line 13.
B. Just after line 14.
C. Just after line 15.
D. Just after line 16 (that is, as the method returns).
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.
最新试题
What is the output if the main() method is run?()
Which statement is true?()
What is the result?()
Which three changes should be made to adapt this class to be used safely by multiple threads?()
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?()
Which statement is true about the set variable on line 12?()
Which statement is true?()
What is the result?()
Which statement is true?()