INHERINTANCE & POLYMORPHISM

Plan your website and create the next important tasks for get your project rolling

Get Started. It's Free
or sign up with your email address
INHERINTANCE & POLYMORPHISM by Mind Map: INHERINTANCE & POLYMORPHISM

1. Type of relationship

1.1. Is-A relationship

1.1.1. obtaining the features of another class using inheritance concept with extands keyword

1.1.2. subsumption relationship between abstraction

1.2. Part-Of relationship

1.2.1. use of instance variable that reference to other object

1.2.2. both entities are interdependent of each other

1.2.3. example:heart is a part of body

1.3. Has-A relationship

1.3.1. object of one class is created as data member in another class the relationship between these two classes

1.4. Uses-A relationship

1.4.1. using an object of another class the relationship between these two classes

2. Constructors

2.1. used to initialize the object's state

2.2. contains collection of statement that are executed at time of Object creation

2.3. created using new() keyword at least one constructor is invoked to assign initial values to the data member of the same class

2.4. Rule for writting constructor

2.4.1. constructor(s) of a class must has same name as the class name in which it resides

2.4.2. a constructor in Java can not be abstract,final,static and Synchronized

2.4.3. access modifiers can be used in constructor declaration to control its access which other class can call the constructor

3. Extends keyword

3.1. the keyword used to inherit the properties of a class

4. Super and this keyword

4.1. THIS KEYWORD

4.1.1. reserved keyword in Java ,we can't use it as an identifier

4.1.2. used to refer current-class's instance as well as static member

4.2. SUPER KEYWORD

4.2.1. used to refer super-class's instance as well as static members

5. Overriding method

5.1. is a feature that allows a subclass or child class to provide a specific implementation of a method that is already provided by one of its super classes

5.2. when a method in a subclass has the same name,same parameters and same return type as a method in itssuper class

5.3. Rule for method overriding

5.3.1. Overriding and Access-Modifiers

5.3.2. Final method can not be overridder

5.3.3. Static method can not be overridden(Method overridding vs Method hiding)

6. Inheritance in java

6.1. Single Inheritance

6.1.1. subclasses inherit the features of one superclass

6.1.2. classs A is a base class for the derived class B

6.2. Multilevel Inheritance

6.2.1. derived class will be inheriting a base class

6.2.2. class A serves as base class for derived class B which turn sereves as a base class for the derived class C

6.2.3. class cannot directly access the grandparent's member

6.3. Multiple Inheritance

6.3.1. one class can have more than one superclass and inherit features from all parent classes

6.3.2. can achieve multiple inheritance only through interfaces

6.3.3. class C is derived from interface A and B