• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

class

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is a class subclass of itself?
 
Tony Alicea
Desperado
Sheriff
Posts: 3226
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not in Java.
 
Gopinath Rajgopal
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The complete reference by Patrick Naughton says it is - ie. every class is a sub class of itself. Only a "strict" sub class of a class cannot include itself.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Different people in OOP have slightly different definitions of "subclass", but in this case the definition Naughton uses is not the one used in Java. The JLS has a precise definition of subclass which does not include the class itself - only other classes which are extended from it, and their "descendents". If you see the word "subclass" on the exam, you can assume this is the definition used.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jim Yingst:
Different people in OOP have slightly different definitions of "subclass", but in this case the definition Naughton uses is not the one used in Java. The JLS has a precise definition of subclass which does not include the class itself - only other classes which are extended from it, and their "descendents". If you see the word "subclass" on the exam, you can assume this is the definition used.

Thanks! All for replying.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic