早教吧作业答案频道 -->其他-->
Java接口,继承QUESTION31Given:1.interfaceA{publicvoidaMethod();}2.interfaceB{publicvoidbMethod();}3.interfaceCextendsA,B{publicvoidcMethod();}4.classDimplementsB{5.publicvoidbMethod(){}6.}7.classEextendsDimp
题目详情
Java接口,继承
QUESTION 31
Given:
1. interface A { public void aMethod(); }
2. interface B { public void bMethod(); }
3. interface C extends A,B { public void cMethod(); }
4. class D implements B {
5. public void bMethod(){}
6. }
7. class E extends D implements C {
8. public void aMethod(){}
9. public void bMethod(){}
10. public void cMethod(){}
11. }
What is the result?
A. Compilation fails because of an error in line 3.
B. Compilation fails because of an error in line 7.
C. Compilation fails because of an error in line 9.
D. If you define D e = new E(), then e.bMethod() invokes the version of bMethod() defined in Line 5.
E. If you define D e = (D)(new E()), then e.bMethod() invokes the version of bMethod() defined in Line 5.
F. If you define D e = (D)(new E()), then e.bMethod() invokes the version of bMethod() defined in Line 9.
Answer: F
这里的强制类型转换十分不理解 还请高手详细解析一下这题
QUESTION 31
Given:
1. interface A { public void aMethod(); }
2. interface B { public void bMethod(); }
3. interface C extends A,B { public void cMethod(); }
4. class D implements B {
5. public void bMethod(){}
6. }
7. class E extends D implements C {
8. public void aMethod(){}
9. public void bMethod(){}
10. public void cMethod(){}
11. }
What is the result?
A. Compilation fails because of an error in line 3.
B. Compilation fails because of an error in line 7.
C. Compilation fails because of an error in line 9.
D. If you define D e = new E(), then e.bMethod() invokes the version of bMethod() defined in Line 5.
E. If you define D e = (D)(new E()), then e.bMethod() invokes the version of bMethod() defined in Line 5.
F. If you define D e = (D)(new E()), then e.bMethod() invokes the version of bMethod() defined in Line 9.
Answer: F
这里的强制类型转换十分不理解 还请高手详细解析一下这题
▼优质解答
答案和解析
E是D的子类所以E的实例可以声明为D类型变量e声明类型是D( D e ), 而实际类型是E( new E() ),不需要进行显示类型转换D e = (D)(new E()) 和 D e = new E()没有区别因为把变量e声明为D类型,D实现(implements)B,...
看了 Java接口,继承QUEST...的网友还看了以下:
直流电源的总功率P总随外电压U变化的关系图线为什么不是二次函数抛物线P=EI=U*E-U)/r,纠 2020-04-26 …
连字成词(英语)l u o e b s r u s r e t o s w a e s r t e 2020-05-14 …
matlab求微分方程,常数项比如y=dsolve("Du=((a-u-b)*e-u*d)/(e* 2020-05-14 …
e^x^2求导看成f'(u)f(u)=u^2u=e^x------>f'(u)=2u*u'=2e^ 2020-06-12 …
物理中的定义式我们老师说定义式的左右两边无关,就像E=F/Q不能说E与F成正比,与Q成反比,E只与 2020-06-14 …
一根电阻丝在通过2C的电量时,消耗电能是8J.若在相同时间内通过4C的电量,则该电阻丝两端所加电压 2020-06-17 …
关于电动势1.电源电动势的一定不变的吗?2.通电前后的电动势有变化吗?E=U内+U外,断电时,U外= 2020-11-20 …
(e)(a)(r)thush(e)(r)sh(i)(r)tl(e)(a)(r)ncol(o)(u)( 2020-11-27 …
U路=E-Ir①U路=I*(R外)②(Ⅰ)②式是否正确?(如果正确,回答(Ⅱ),如果不正确,理U路= 2020-12-27 …
部分积分法的时候是取求导数比较简单的项是u吗?e^x乘以cosxdx的时候教科书是取u=e^xdv= 2020-12-31 …