aspose file tools*
The moose likes Beginning Java and the fly likes Basic Inheritance Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Basic Inheritance Question" Watch "Basic Inheritance Question" New topic
Author

Basic Inheritance Question

kalpana Kumar
Ranch Hand

Joined: Jul 03, 2003
Posts: 65
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

Joined: Aug 03, 2002
Posts: 7729
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 ]

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
You wrote this code. Did you have any purpose in mind?
Francis Palattao
Ranch Hand

Joined: Sep 22, 2004
Posts: 91
<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.


SCJP 1.4 <br />SCWCD 1.4 (preparing)<br />SCBCD 1.3 (coming soon)
jefff willis
Ranch Hand

Joined: Sep 29, 2004
Posts: 113
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()..."
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Basic Inheritance Question
 
Similar Threads
Inheritance Question
equals and hashCode??
initilization of method
initialization sequence
interface