-:Inheritance VS Polymorphism:-
Presented By:-
Rajdeep Saha
Dept:- C.S.E; Year:- 3rd; Sem5th
Roll no:- 13000121119
What is Inheritance ?
Inheritance in Java is a mechanism in which one object acquires all the
properties and behaviors of a parent object. It is an important part
of OOPs (Object Oriented programming system).
The idea behind inheritance in Java is that you can create
new classes that are built upon existing classes. When you inherit from an
existing class, you can reuse methods and fields of the parent class.
Moreover, you can add new methods and fields in your current class also.
Types of Inheritance:-
• Single
• Multilevel
• Hierarchial
Single Inheritance:-
CLASS A
CLASS B
Multilevel Inheritance:-
CLASS A
CLASS B
CLASS C
Hierarchial Inheritance:-
CLASS A
CLASS B CLASS C
Polymorphism:-
Polymorphism in Java is a concept by which we can perform a single
action in different ways. Polymorphism is derived from 2 Greek words: poly
and morphs. The word "poly" means many and "morphs" means forms. So
polymorphism means many forms.
Types of Polymorphism:-
• Compile time polymorphism
• Runtime polymorphism
Compile-time polymorphism:-
Test
Void fun(int a)
Void fun(int a , int b)
Void fun(char a)
Overloading
Base
Void fun(int a)
Derived
Void fun(int a)
overriding
Runtime polymorphism:-
Difference between Inheritance and Polymorphism:-
• Inheritance is one in which a new class is
created(derived class) that inherits the features from
the already existing class(Base class).
• It is basically applied to classes.
• Inheritance supports the concept of reusability and
reduces code length in object-oriented programming.
• Inheritance can be single, hybrid, multiple, hierarchical
and multilevel inheritance.
• It is used in pattern designing.
Inheritance Polymorphism

Inheritance VS Polymorphism.pptx

  • 1.
    -:Inheritance VS Polymorphism:- PresentedBy:- Rajdeep Saha Dept:- C.S.E; Year:- 3rd; Sem5th Roll no:- 13000121119
  • 2.
    What is Inheritance? Inheritance in Java is a mechanism in which one object acquires all the properties and behaviors of a parent object. It is an important part of OOPs (Object Oriented programming system). The idea behind inheritance in Java is that you can create new classes that are built upon existing classes. When you inherit from an existing class, you can reuse methods and fields of the parent class. Moreover, you can add new methods and fields in your current class also.
  • 3.
    Types of Inheritance:- •Single • Multilevel • Hierarchial
  • 4.
  • 5.
  • 6.
  • 7.
    Polymorphism:- Polymorphism in Javais a concept by which we can perform a single action in different ways. Polymorphism is derived from 2 Greek words: poly and morphs. The word "poly" means many and "morphs" means forms. So polymorphism means many forms.
  • 8.
    Types of Polymorphism:- •Compile time polymorphism • Runtime polymorphism
  • 9.
    Compile-time polymorphism:- Test Void fun(inta) Void fun(int a , int b) Void fun(char a) Overloading Base Void fun(int a) Derived Void fun(int a) overriding
  • 10.
  • 11.
    Difference between Inheritanceand Polymorphism:- • Inheritance is one in which a new class is created(derived class) that inherits the features from the already existing class(Base class). • It is basically applied to classes. • Inheritance supports the concept of reusability and reduces code length in object-oriented programming. • Inheritance can be single, hybrid, multiple, hierarchical and multilevel inheritance. • It is used in pattern designing. Inheritance Polymorphism