POLYMORPHISM
OBJECT ORIENTED CONCE
Team
DURNIBAR
Encapsulation Abstraction Inheritance Polymorphism
PILLERS OF OOP
Abdul Ahad Nur
ID: 0242310005341227
Dept. of Software Engineering
S. M. Hasib Hasnain
ID: 0242310005341116
Dept. of Software Engineering
Sarowar Mahfuz Suman
ID: 0242310005341345
Dept. of Software Engineering
Md Nahid
ID: 213-35-809
Dept. of Software Engineering
Sazid Hossain
ID: 0242310005341328
Dept. of Software Engineering
OUR TEAM
Team
DURNIBAR
POLY MORPHISM
Greek
Words
POLY + MORPHS
MANY + FORMS
MEANING OF POLYMORPHISM
EXAMPLE OF POLYMORPHISM
Polymorphism: A
person can 'eat' in
different ways - with
chopsticks, a fork, or
hands - but the action
remains 'eating'."
PETER is also
Polymorphic !!!
A high school student, Peter goes to
school, and hang out with friends.
As Spider Man, he bashes up
buddies. Peter has multiple
behaviors based on context. Peter
is polymorphic.
POLY MORPHISM
Run Time / Dynamic
Polymorphism
Compile Time / Static
Polymorphism
 Method Overloading
 Constructor Overloading
 Method Hiding
 Method Overriding
Example: Example:
CLASSIFICATIONS OF POLYMORPHISM
COMPILE TYPE POLYMORPHISM => METHOD OV
Compile-time or static polymorphism:
1. Determined at compile time.
2. Implemented through method overloading and function templates.
3. No runtime overhead for method resolution.
4. Enhances code efficiency.
5. Errors detected early during compilation.
Compile-time
polymorphism selects
the appropriate
method or function
based on their
signatures during
compilation.
IIUSTRATION => METHOD OVERLOADIN
If subclass (child class) has the same
method as declared in the parent
class, it is known as method
overriding in Java.
RUN TIME POLYMORPHISM => METHOD OVE
Runtime polymorphism:
1. Determined at runtime.
2. Enabled by inheritance and virtual functions.
3. Late binding.
4. Uses virtual function tables (vtables) in some languages.
5. Enhances code flexibility and extensibility.
RUN TYPE POLYMORPHISM => METHOD OVER
 The method must have the same
name as in the parent class
 The method must have the same
parameter as in the parent class.
 There must be an IS-A relationship
(inheritance).
Rules for Java Method Overriding
ADVANTAGES OF POLYMORPHISM
Code Reusability
Polymorphism enables the reuse of code across different parts of
your program by allowing objects of different classes to be treated
interchangeably through a common interface or superclass.
Ease of Maintenance
By using polymorphism, you can make changes to the behavior of
your program by modifying the implementations of methods in
subclasses or implementing new interfaces, without needing to
modify the calling code.
Polymorphism facilitates adding new functionality to your
application by extending existing classes or implementing new
interfaces, without impacting existing code that relies on
polymorphic behavior.
Enhanced Extensibility
Flexibility in Design
With polymorphism, you can design your classes and methods to
be more flexible and adaptable to changes, as you can substitute
objects of different classes that implement the same interface or
inherit from the same superclass.
Q/A SESSION
I cannot teach anybody
anything. I can only make
them think, make them
inspire to ask question.
- Socrates
That’s all.
Thank you for your time and attention.
We appreciate it!

java polymorphism example program oracal.pptx

  • 1.
  • 2.
    Encapsulation Abstraction InheritancePolymorphism PILLERS OF OOP
  • 3.
    Abdul Ahad Nur ID:0242310005341227 Dept. of Software Engineering S. M. Hasib Hasnain ID: 0242310005341116 Dept. of Software Engineering Sarowar Mahfuz Suman ID: 0242310005341345 Dept. of Software Engineering Md Nahid ID: 213-35-809 Dept. of Software Engineering Sazid Hossain ID: 0242310005341328 Dept. of Software Engineering OUR TEAM Team DURNIBAR
  • 4.
    POLY MORPHISM Greek Words POLY +MORPHS MANY + FORMS MEANING OF POLYMORPHISM
  • 5.
    EXAMPLE OF POLYMORPHISM Polymorphism:A person can 'eat' in different ways - with chopsticks, a fork, or hands - but the action remains 'eating'."
  • 6.
    PETER is also Polymorphic!!! A high school student, Peter goes to school, and hang out with friends. As Spider Man, he bashes up buddies. Peter has multiple behaviors based on context. Peter is polymorphic.
  • 7.
    POLY MORPHISM Run Time/ Dynamic Polymorphism Compile Time / Static Polymorphism  Method Overloading  Constructor Overloading  Method Hiding  Method Overriding Example: Example: CLASSIFICATIONS OF POLYMORPHISM
  • 8.
    COMPILE TYPE POLYMORPHISM=> METHOD OV Compile-time or static polymorphism: 1. Determined at compile time. 2. Implemented through method overloading and function templates. 3. No runtime overhead for method resolution. 4. Enhances code efficiency. 5. Errors detected early during compilation.
  • 9.
    Compile-time polymorphism selects the appropriate methodor function based on their signatures during compilation. IIUSTRATION => METHOD OVERLOADIN
  • 10.
    If subclass (childclass) has the same method as declared in the parent class, it is known as method overriding in Java. RUN TIME POLYMORPHISM => METHOD OVE
  • 11.
    Runtime polymorphism: 1. Determinedat runtime. 2. Enabled by inheritance and virtual functions. 3. Late binding. 4. Uses virtual function tables (vtables) in some languages. 5. Enhances code flexibility and extensibility.
  • 12.
    RUN TYPE POLYMORPHISM=> METHOD OVER  The method must have the same name as in the parent class  The method must have the same parameter as in the parent class.  There must be an IS-A relationship (inheritance). Rules for Java Method Overriding
  • 13.
    ADVANTAGES OF POLYMORPHISM CodeReusability Polymorphism enables the reuse of code across different parts of your program by allowing objects of different classes to be treated interchangeably through a common interface or superclass. Ease of Maintenance By using polymorphism, you can make changes to the behavior of your program by modifying the implementations of methods in subclasses or implementing new interfaces, without needing to modify the calling code.
  • 14.
    Polymorphism facilitates addingnew functionality to your application by extending existing classes or implementing new interfaces, without impacting existing code that relies on polymorphic behavior. Enhanced Extensibility Flexibility in Design With polymorphism, you can design your classes and methods to be more flexible and adaptable to changes, as you can substitute objects of different classes that implement the same interface or inherit from the same superclass.
  • 15.
    Q/A SESSION I cannotteach anybody anything. I can only make them think, make them inspire to ask question. - Socrates
  • 16.
    That’s all. Thank youfor your time and attention. We appreciate it!