reference type transition
class Ex7_7 {
public static void main(String args[]) {
Car c = new Car();//the object is Car type!!!
FireEngine fe = (FireEngine)c;//even ClassCast is proceeded and compiler does not catch issue
fe.water();//there is execution error! because in Car class, there is NO water() method!
}
}Last updated