Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java without Inheritance.  RSS feed

 
Fame Devon
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello frnds, I know its a silly question, and thats why I'm putting it here.

I was reading the Cathy Bert SCJP6 book chapter 2 when I stumbled accross a sentence.

"Its safe to say that its almost (almost?) impossible to write a program without inheritance.

I tried thinking, but even the HELLO WORLD program uses inheritance from java.lang.object.

So is there a code that can be written and executed without inheritance.

Regards,
Saurabh.

PS: Please don't kill me for this one.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All classes implicitly inherit from java.lang.Object, and methods are always defined inside a class; it's not possible to have a method outside a class. So in that sense, it's not possible to write a Java program that does not use inheritance at all.
 
Fame Devon
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jesper... That cleared the doubt...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!