Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Basic Inheritance Question

 
kalpana Kumar
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am preparing for JCP.
This is a very preliminary question
Here is my sample code

t = b;//what is the use of this assignment when I am not able to access the
methods of b?.

I would like to know in the real-time scenario.

Thanks
[ November 08, 2004: Message edited by: Barry Gaunt ]
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved here from SCJP.


I would like to know in the real-time scenario


Could you please explain this?
[ November 08, 2004: Message edited by: Barry Gaunt ]
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You wrote this code. Did you have any purpose in mind?
 
Francis Palattao
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<quote>
t = b;//what is the use of this assignment when I am not able to access the
methods of b?.
</quote>

you get to use polymorphism. if you have another object that is subclassed by T and have a different method implementation. You will now use that objects implementation.
 
jefff willis
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Think of it terms of using lists...





Is basically doing the same thing...

There was a thread on here not long ago that spoke more specifically about that particular example. Maybe you could do a search on it...

I'm not sure how you would find it exactly, but try searching for this as the topic: "Initializing ArrayList()..."
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic