Mind map
Inheritance, extending a class
Map content
Inheritance, extending a class
Parent Class/ base class/superclass/orginal class
- The object is the ultimate superclass
- "Is-a" relationship with subclass
- Consequence of this relationship is that it is legal to assign an instance of subclass to reference variable of parent type
- Example: Animal animal = new Bird();
- Consequence of this relationship is that it is legal to assign an instance of subclass to reference variable of parent type
- If constructor is not explicitly written in subclass, the compiler will implicitly add a no argument constructor
Child class/subclass/ derived of parent class
- Add new method/fields, and override existing methods to change behaviors
- Can be extended unless made inextensible by declaring it final
- Special type of the superclass
- inherits all public methods and fields of superclass.
- Not able to access the private methods of superclass
- Able to access default methods and fields, if superclass and subclass are in the same model
- use new to create an instance of class
- Type Casting: ability to cast an object to another type; rule is you can only cast an instance of a subclass to its parent class
Inheritance allows one to add some funcationality that does not exist in orginal class
- To extend a class use the keyword "extend" keyword in class declaration; only one class can be extended in Java.
Method Overriding: changing the behavior of a method in parent class through extending a class
- Happens when method in subclass has the same signature as method in parent class
Information
- Description
- Mind Map on Inheritance, extending a class, created by kiara thompson on 21/11/2019.
- Created by
- kiara thompson
- Views
- 0
- Rating