I am a bit confused on the difference between Inheritance and Run time
Polymorphism.
Take the example of:
Person person3 = new InternationalStudent();
person3.myMethod("test5");
and,
InternationalStudent person4 = new InternationalStudent();
person4.myMethod("test7");
petrson3 is of type Person, but an instance object of
InternationalStudent, so it can reference all the fields and methods
of Persons and InternationalStudent, any method of the same name in
the superclass are overridden by that of the subclass.
person4 is of type InternationalStudent and an object instance of
InternationalStudent, so it can reference all the field and methods of
InternationalStudent and all that of the super class. (Student,
Person, Object),
any method of the same name in the super class are overridden class.
person3 and person4 seems to go through exactly the same processes, I
am sure there is a subtle difference, but I can’t quite work it out
norman.
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---