wood burning stoves 2.0*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 410

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: 38107
    
  22
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
 
Don't get me started about those stupid light bulbs.
 
subject: Java Inheritance
 
Similar Threads
Would like to get the Type of a member of a class, I'm boxing with Generic, java erasure
IS-A/HAS-A relationship
Problem in Generic Method Declaration
extending class clarifications
HFSJ Question