A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Joined: Jun 21, 2001
Jul 27, 2001 19:05:00
Sub class reference can be assigned to super class reference.
But super class reference cannot be assigned to sub class reference(without explicit casting).Why it is so?
Can anyone explain me in detail?
Marilyn de Queiroz
Joined: Jul 22, 2000
Jul 27, 2001 21:05:00
The Subclass object ALWAYS is a Superclass object by definition. However, the reverse is not true.
For example, Dog "is a" Animal, but Animal is NOT always a Dog.
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
rocket mass heater
Please explain these answers
interfaces and subclasses
object refrence casting
reference variable assignment problem
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014