reference type transition

change only the nubmer of usable members! only between parent-child relation NOT siblings

type transition of primitive type, the value is changed. ex) (int)3.6 => 3

diminishing the number of usable members is okay but vice versa increasing the number of usable memberw is see is NOT recommended.

basically, reference type transition is allowed.

The important thing is what object(members) reference type var is indicating . Figure out the real object that reference type var is indicating. The reference type variable must NOT be more than the number of object's usable members.

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