This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.lang.Object

 
shri mon
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can we write a class that will not extend java.lang.Object?
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No , it is impicitly extended ...

if you are writing a class A & that class is already extending a class B . and you are thinking that it has one superclass so it can't have another , you are thinking wrong ... because class B is extending Object class . So ultimately class A is a subclass of Object .
 
Andris Jekabsons
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, every Java class extends Object indirectly. You can still write "class A extends Object" but that will have no effect.
Andris
 
shri mon
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot..
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by shri mon:
can we write a class that will not extend java.lang.Object?


no.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic