单项选择题
package foo;
public class Outer {
public static class Inner {
}
}
Which statement is true?()
A. Compilation fails.
B. An instance of the Inner class can be constructed with “new Outer.Inner()”.
C. An instance of the Inner class cannot be constructed outside of package foo.
D. An instance of the Inner class can be constructed only from within the Outer class.
E. From within the package foo, and instance of the Inner class can be constructed with “new Inner()”.
相关考题
-
单项选择题
class A { public A() { System.out.println(“hello from a”); } } class B extends A { public B () { System.out.println(“hello from b”); super(); } } public class Test { public static void main(String args[]) { A a = new B(); } } What is the result when main is executed?()
A. Compilation fails.
B. hello from a
C. hello from b
D. hello from b hello from a
E. hello from a hello from b -
多项选择题
Whichtwoarebenefitsoffullyencapsulatingaclass?()
A. Performance of class methods is improved.
B. Implementation details of the class are hidden.
C. Access modifiers can be omitted on class data members.
D. Code that uses the encapsulation class can access data members directly.
E. Internal operation of the class can be modified without impacting clients of that class. -
单项选择题
class A { public byte getNumber() { return 1; } } class B extends A { public short getNumber() { return 2; } public static void main(String args[]) { B b = new B(); System.out.println(b.getNumber()); } } What is the result?()
A. 1
B. 2
C. An exception is thrown at runtime.
D. Compilation fails because of an error in line 8.
E. Compilation fails because of an error in line 14.
