black

SCJP程序员认证考试

登录

单项选择题

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?()

单项选择题 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?()

多项选择题 1. class BaseClass {  2. private float x = 1.of;  3. protected float getVar() { return x; }  4. }  5. class SubClass extends BaseClass {  6. private float x = 2.Of;  7. // insert code here 8. }   Which two are valid examples of method overriding when inserted at line 7?()

All Rights Reserved 版权所有©易学考试网(yxkao.com)

备案号:湘ICP备2022003000号-3