• Post Reply Bookmark Topic Watch Topic
  • New Topic

Super class reference Subclass object  RSS feed

 
nagasaichaitanya Puttamshetty
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I came across the concept super class reference and sub class object. I understood the concept, how everything works. But i am not able to relate this concept to a scenario where it could be applied.

It would be helpful if a scenario is provided for this concept. Thanks in advance .

 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you have a superclass of animal, you can have sub-classes of dogs, cats, birds, elephants, etc.

then, you can create a zoo collection - like an array - of animals. everything in the array is an animal, so you can use an animal reference to point to each element, in order.
 
nagasaichaitanya Puttamshetty
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank for the example its much more clear now
 
Campbell Ritchie
Marshal
Posts: 56576
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the Ranch
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!