GoConqr has a new look! Let us know what you think.

Mind map

Inheritance

Darren Hallihan English

Map content

Inheritance

  1. Benefits of inheritance

    • Gives you the opportunity to add functionalities not available in the parent class
    • Gives you the chance to alter the behavior of the existing class to better suit your specific needs
  2. extends: Keyword used to extend a class

    • ex. public class Parent {} public class Child extends Parent {}
  3. Is-a relationship: A relationship between subclasses and a superclass where the subclass "is a" special type of the super class. This relationship does not hold true in the other way

    • e.g. A cat, a dog, and a cow are all animals, but an animal is not necessarily a cat, dog, or cow
  4. Accessibility

    • Public, protected, and default methods and fields of a superclass are accessible from a subclass. On the other hand, private methods and fields are not accessible
  5. Overriding: changing the behavior of a method from the superclass in the subclass

    • Overriding a method is done by writing the same method signature from the superclass and then either altering the arguments entered as parameters or changing the code within the method
  6. Calling a superclass's constructor

    • Whenever you create an object of a subclass, the java compiler implicitly instantiates all the superclasses of the specified subclass
    • super: keyword used to explicitly call the constructor of the direct superclass of a subclass. in addition it can be used to access hidden members and overridden methods of the superclass
  7. Type Casting: Casting an object of one type to another type

    • Downcasting: Casting an object of a superclass to an object of a subclass
    • Upcasting: Casting an object of a subclass to an object of a superclass
  8. Final: keyword used to prevent a class from being extended

  9. instanceof: keyword used to test if an object is of a specified type

Information

Description
Mind Map on Inheritance, created by Darren Hallihan on 21/11/2019.
Created by
Darren Hallihan
Views
0
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?