• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Inheritance Theory Question  RSS feed

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been given a list of 9 possible types of inheritance.
I do not understand 2 bad types of inheritance:

The first is called construction:
- "Subclass modifies the interface of the parent's class but not it's functionality"
- Subclass is not a subtype, can't be substituted
- eg Set class inheriting from a list class

The second is called limitation:
- "Subclass modifies the set operations to exclude some operations"
- "eg UnprintableCharAtom is a subclass of CharAtom. Would like to override the print method in CharAtom with something else

Could you help clarify in simple terms and if possible an example.
 
Sheriff
Posts: 4294
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you quote your source?  Is this a school handout?
 
Glenn Jayasuriya
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute Snortum wrote:Can you quote your source?  Is this a school handout?

It's verbatim from my classroom notes.
I understand limitation now. But I still don't get construction.
 
Knute Snortum
Sheriff
Posts: 4294
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand it either.  I do know a few things though:

  • Both Set and List are interfaces in Java, and they and they extend the Collection interface. 
  • You don't modify an interface, you implement it.
  • If two classes implement the same interface, they have the same functionality, although possible not the same implementation.
  • Creating a class creates a type.  You may ar may not be able to cast it to another type.


  • I've never heard of the terms "construction" and "limitation" applied to inheritance before.
     
    It is sorta covered in the JavaRanch Style Guide.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!