开发者

Abstract superlcass help

A is an abstract superclass of the concrete classes B and C. Constr开发者_如何学Gouctors of all three classes do not take parameters. The following variables are defined:

A a;
B b;
C c;

Which one or more of the following assignments will result in an error at compile time?

(i) a = new C();
(ii) b = new C();
(iii) a = new A();
(iv) b = (B) new A();

Any help is appreciated


A is abstract so ANY attempt to create an A outright will fail. Also, the relationship between B and C is not clearly defined but I am betting the second case will fail as well unless B is a superclass of C.


Because A is an abstract superclass of B and C, A cannot be initialized. However, its subclasses can be stored in an object of the type of the superclass (A), since it shares or defines the methods contained in A.

Should be enough to figure it out.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜