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

Mind map

Inheritance

Ryan Plante English

Map content

Inheritance

  1. Definition

    • The process of extending a class
      • All classes extend the java.lang.Object class
  2. Performed using the "extends" keyword

    • Ex: public class Child extends Parent
  3. Uses

    • extending traits from the superclass to various subclasses
      • Ex: All animals might eat, but only some have fins
        • So you would extend "eat" from Animal into Fish and Bird
    • Subclasses can access the superclass' public methods and fields
      • Method Overriding
        • Changing methods from the parent class using the child class
    • Calling a parent class' constructor methods
      • Done implicitly all the way up the chain
      • Can be done explicitly through "super"
    • Type Casting
      • Upcasting: changing the type of a variable to its parent class
      • Downcasting: changing the type to its subclass
        • Only if upcasting was already used for that variable
  4. Prevention

    • Calling something "final" will prevent it from being extended
    • "instanceOf" can tell you what datatype an object is
      • Will return true or false

Information

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

Feedback

What is it about?

What do you think of the new look?

How do you like it?