【发布时间】:2015-06-19 02:08:37
【问题描述】:
我的意思是基类,它本身并没有使用派生类的实例进行初始化。即假设它不是一个抽象类。
class GeomObj{
Colour x;
}
class Triangle extends GeomObj{
largestAngle y;
}
GeomObj u;
//now is the following allowed?Taking into account that u was not initialized using an instance of Triangle in the first place
Triangle v = (Triangle)u;
【问题讨论】:
标签: java polymorphism derived-class base-class