字典翻译 问答 其它 能给解释解释为什么选CD吗(java)1.classSuper{2.privateinta;3.protectedSuper(inta){this.a=a;}4.}...11.classSubextendsSuper{12.publicSub(inta){super(a);}13.publicSub(){this.a=5;}14.}Whichtwo,independently,willall
问题标题:
能给解释解释为什么选CD吗(java)1.classSuper{2.privateinta;3.protectedSuper(inta){this.a=a;}4.}...11.classSubextendsSuper{12.publicSub(inta){super(a);}13.publicSub(){this.a=5;}14.}Whichtwo,independently,willall
问题描述:

能给解释解释为什么选CD吗(java)

1.classSuper{

2.privateinta;

3.protectedSuper(inta){this.a=a;}

4.}

...

11.classSubextendsSuper{

12.publicSub(inta){super(a);}

13.publicSub(){this.a=5;}

14.}

Whichtwo,independently,willallowSubtocompile?(Choosetwo.)

A.Changeline2to:

publicinta;

B.Changeline2to:

protectedinta;

C.Changeline13to:

publicSub(){this(5);}

D.Changeline13to:

publicSub(){super(5);}

E.Changeline13to:

publicSub(){super(a);}

蒋志迪回答:
  C.Changeline13to:publicSub(){this(5);}//执行的是12行,this(5)找的是Sub类的对应构造方法D.Changeline13to:publicSub(){super(5);}//执行的是3行,super(5)找的是父类对应的构造方法...
点击显示
其它推荐
热门其它推荐
  • 其它