• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 21. Packaging Data and Functions... > Accessing the Superclass Using super

Accessing the Superclass Using super

The following two situations commonly arise when you’re working with inheritance hierarchies:


  • You want to create a subclass with a method that overrides a superclass method. However, you occasionally want to access the superclass behavior, or you want your subclass method to combine the superclass behavior with its own added behavior.

  • You have a parent class with instances and a subclass with instances. For example, you have a Bird class with instances and an Auk class with instances. The parent class gives its instances a local property. You want instances of the subclass to have a local copy of that property, too.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint