Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Beginning Java and the fly likes Will every class inherit the object class? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Will every class inherit the object class?" Watch "Will every class inherit the object class?" New topic
Author

Will every class inherit the object class?

Chandra Bairi
Ranch Hand

Joined: Sep 12, 2003
Posts: 152
hello friends,
I have a doubt. Ihave read that every class extends java.lang.Object class implicitly. Does this hold for an interface also? Does a interface extend the java.lang.Object methods?


Thanks,
Shekar
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8876

No.
When some class implements the interface by default the class also extends java.lang.Object.


Groovy
Tom Wolve
Ranch Hand

Joined: Sep 22, 2003
Posts: 32
The simple rule is
interfaces can extend interfaces, but not classes.
classes can extend classes, but not interfaces.
Donald R. Cossitt
buckaroo
Ranch Hand

Joined: Jan 31, 2003
Posts: 401
An interface is essentially a collection of constants and abstract methods. To make use of an interface, you implement the interface in a class - that is, you declare that the class implements the interface and you write the code for each of the methods declared in the interface as part of the class definition.
Check
Learning the Java Language
What is an Interface?
Implementing an Interface

At Java Sun
HTH


doco
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Will every class inherit the object class?
 
Similar Threads
Runnable.toString()?
Question: invoke methods in javax.xml.rpc.Call interface
Regarding Interfaces
Interface
Constructor in interface?