File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Jag Bains
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 661
Eclipse IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I modified your code just a little:

Here's what I got when running it:

Hope this helps...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic