wood burning stoves 2.0*
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 Murach's Java Servlets and JSP this week in the Servlets 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
 
Consider Paul's rocket mass heater.
 
subject: Inheritance question when I have class A extends class B extend baseclass
 
Similar Threads
Not so good with boolean and loops
Generics doubt
Polymorphism
Overridding
Constructors