Unit-4 Inherihance & Polymorphism
Unit-4 Inherihance & Polymorphism
Polymorphism
2 Inheritance
Uses – One class uses the services of another class, either by making
objects of that class or by using static functions of the class.
Has A – One class’s attributes includes one or more object of another
class.
3 Inheritance
Car
Prius
Words Dictionary
- definitions : int
+ main (args : String[]) :
void + definitionMessage() :
void
12
The super Reference
A child class of one parent can be the parent of another child, forming a
class hierarchy
Business
RetailBusin ServiceBusine
ess ss
• Definition-polymorphism
• Types :- 1)Compile Time 2)Run Time
• Compile time polymorphism and its examples.
• Run rime polymorphism and its examples.
• Difference overloading and overriding.
• Advantages of polymorphism.
What is polymorphism?
Compile -Time
Polymorphism
Polymorphism In
Java
Run-Time
Polymorphism
• Compile-time polymorphism refers to
behaviour that is resolved when your Java
class is compiled.
• Method overloading is an example of
compile-time polymorphism. Method
overloading is how you can use method with
same name to do different things based on
the parameters passed.
System.out.println(MultiplyFun.Multiply(2, 7, 3));
}
}
Illustration – Method Overloading
class OperatorOVERDDN {
Code Ease Of
Cleanliness Implementation
Reusability And
Extensibility
Thank you