Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

JavaWorld Daily Brew

polymorphism


Tags:

I'm trying to understand polymorphism and I'm confused about what it means when a reference of a class holds a reference to one of its subclasses. For example:

Car Mustang = new Ford();

Is Mustang a Car or a Ford, or both???? And why would it be necessary for a Mustang to be a Car when the Ford object would have more details and specific methods in it. It seems as though Ford would be more useful so why reference from a Car object?

Thanks,
Von