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
Rocket clouds
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. Super and this keyword

3.1. THIS KEYWORD

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

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

3.2. SUPER KEYWORD

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

4. Overriding method

4.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

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

4.3. Rule for method overriding

4.3.1. Overriding and Access-Modifiers

4.3.2. Final method can not be overridder

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

5. Inheritance in java

5.1. Single Inheritance

5.1.1. subclasses inherit the features of one superclass

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

5.2. Multilevel Inheritance

5.2.1. derived class will be inheriting a base class

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

5.2.3. class cannot directly access the grandparent's member

5.3. Multiple Inheritance

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

5.3.2. can achieve multiple inheritance only through interfaces

5.3.3. class C is derived from interface A and B

6. Extends keyword

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