This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Will every class inherit the object class?

 
Chandra Bairi
Ranch Hand
Posts: 152
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No.
When some class implements the interface by default the class also extends java.lang.Object.
 
Tom Wolve
Ranch Hand
Posts: 32
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The simple rule is
interfaces can extend interfaces, but not classes.
classes can extend classes, but not interfaces.
 
Donald R. Cossitt
buckaroo
Ranch Hand
Posts: 401
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic