This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Inheritance question when I have class A extends class B extend baseclass 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 "Inheritance question when I have class A extends class B extend baseclass" Watch "Inheritance question when I have class A extends class B extend baseclass" New topic
Author

Inheritance question when I have class A extends class B extend baseclass

Jag Bains
Greenhorn

Joined: Sep 08, 2005
Posts: 3
Hi,

I have a question on inheritance.

Say I have 3 classes

From the toString Method in Dog how do I call the toString method in Mammal. I have tried super and it seems to go straight to Animal class.

Am I missing something, or got something wrong in my code?

Cheers

Jag
[ September 12, 2005: Message edited by: Michael Ernest ]
Arun Kumarr
Ranch Hand

Joined: May 16, 2005
Posts: 513

I'm afraid you cannot override the toString() method of Object by assigning a protected access.

The code you've given should throw a compiler error.


If you are not laughing at yourself, then you just didn't get the joke.
Michael Ernest
High Plains Drifter
Sheriff

Joined: Oct 25, 2000
Posts: 7292

I modified your code just a little:

Here's what I got when running it:

Hope this helps...


Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Inheritance question when I have class A extends class B extend baseclass
 
Similar Threads
Generics doubt
Not so good with boolean and loops
Overridding
Polymorphism
Constructors