1 / 9

Chapter 8

Chapter 8. Serious Polymorphism. Overview. When to not instantiate Abstract Classes Abstract Methods Class Object Casting and Object reference Multiple Inheritance Problem Interfaces. When to not instantiate. Sometimes a superclass is so generic as to be pointless to instantiate

carver
Télécharger la présentation

Chapter 8

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 8 Serious Polymorphism

  2. Overview • When to not instantiate • Abstract Classes • Abstract Methods • Class Object • Casting and Object reference • Multiple Inheritance Problem • Interfaces

  3. When to not instantiate • Sometimes a superclass is so generic as to be pointless to instantiate • This is not bad because the framework for the sub classes is still created • For example, creating a new object of type animal is pointless if in ALL other subclasses all properties are overridden

  4. Abstract Classes • A class can be protected from instantiation by the abstract command • This prevents a new object instance to be created. • You can still make a reference variable however

  5. Abstract Methods • Abstract classes can still have inheritable methods • To make sure that subclasses must write their own methods, individual methods can be made abstract • This can only be done in abstract classes

  6. Class Object • There is the mother of all superclasses, class Object • Every class by default inherits directly or indirectly from class Object • Some Object methods: • equals() • getClass() • hashCode() • toString()

  7. Casting and Object reference

  8. Multiple Inheritance Problem

  9. Interfaces

More Related