aspose file tools*
The moose likes Beginning Java and the fly likes Java Inheritance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java Inheritance" Watch "Java Inheritance" New topic
Author

Java Inheritance

Adarsh Raj
Greenhorn

Joined: Mar 18, 2009
Posts: 5
if every class in java automatically extends the base class Object, how is it possible to write such as

concerning the fact that, java allows at a time only one class to be extended.

Adz
pawan chopra
Ranch Hand

Joined: Jan 23, 2008
Posts: 411

Adarsh Raj wrote:if every class in java automatically extends the base class Object, how is it possible to write such as

concerning the fact that, java allows at a time only one class to be extended.

Adz


Its like SomeClass extends AnotherClass and AnotherClass extends Object class. So at a time one class is extending single class. If you do not extend any class compiler inherits Object class by default.


Pawan Chopra
SCJP - DuMmIeS mInD
Muhammad Khojaye
Ranch Hand

Joined: Apr 12, 2009
Posts: 449

pawan is right. SomeClass has a super type of Object but not as the direct super class.


http://muhammadkhojaye.blogspot.com/
nick kaushik
Ranch Hand

Joined: Sep 25, 2009
Posts: 48

compiler first checks whether you have inherited a class or not...if you haven't then it puts the extend statement of the base class itself....


"ye shall know the truth & the truth shall set you free..."
Adarsh Raj
Greenhorn

Joined: Mar 18, 2009
Posts: 5
Thanks to everyone who replied. I got the answer i was looking for.

Adz
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39436
    
  28
Adarsh Raj wrote:Thanks to everyone who replied. I got the answer i was looking for.

Adz
I think you got the right answer too!

And welcome to JavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Inheritance