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

Mind map

Inheritance | Mental Map

Phenom Cloud English

Map content

Inheritance | Mental Map

  1. Inheritance

    • Also commonly recognized as subclassing, inheritance in object-oriented programming pertains to the extending process. Specifically, whenever a new class is created with the Java "extends" keyword, it is extended from a parent or superclass in a parent-child or is-a relationship. Consequently, the behaviors and attributes of the superclass are inherited to the subclasses and thus the opportunity is provided to override existing functions or add new methods. In order to prevent class extension and inheritance however, the class can be declared as final. It is also important to note that all Java classes are inherently extended from the java.lang.Object class, which ultimately serves as the dominant superclass above all others.
      • Superclass Constructors
        • Whenever a subclass is instantiated through calling one of its constructors, a no-argument constructor is invoked of the direct superclass. This process continually repeats until the constructor of the java.lang.Object class is ultimately reached. As a result, when forming any child object, all of its parent classes are also instantiated. Focusing upon the Java "super" keyword, any constructor of the parent class, besides the default no-argument constructor, may be directly summoned from a child class' constructor.
          • Method Overriding
            • Within a subclass, any of the superclass's public and protected methods or fields may be directly interacted with. Typically known as method overriding, any subclass method that contains the same signature as a superclass' public or protected method can thus be manually adjusted. For instance, when working with a Human superclass and its attack method, any child or subclasses may approach it uniquely depending upon which roleplaying class is represented. In this scenario, a warrior or mage subclass is a human and may use magic or melee weapons in combat. Despite this, not all humans are mages or warriors necessarily, nor do they all inherit the attack method with the same arsenal or strategies. Nonetheless, if the method or field in the parent class is declared private or final, it can not be directly overridden by any child classes. Moreover, if only the names are identical but the list of arguments is not, then it is method overloading as opposed to overriding.
              • Type Casting
                • Through typecasting, any instance of a subclass may adopt the type of its superclass. When a child object is assigned to a reference variable of the parent's type, the process is known as upcasting. On the other hand, if the parent class reference is focusing upon a subclass instance and its type is casted down the inheritance hierarchy, then the process is recognized as downcasting.
              • InstanceOf & Super Keyword
                • In addition to modifying which parent constructor is called from the child constructor, the super keyword can also prove useful in calling a hidden member or overridden method within a superclass. Specifically, since super represents an object of any direct parent classes, using super.memberName can return any visible member of the parent class. Furthermore, the instanceof keyword is beneficial to test if a certain object is identified as a specified type. For instance, when using the previously mentioned keyword to determine if a subclass is a type of its superclass, the response would return as true.

Information

Description
Mind Map on Inheritance | Mental Map, created by Phenom Cloud on 15/05/2019.
Created by
Phenom Cloud
Views
0
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?