• Polymorphism in Java | Java Tutorial

    Polymorphism allows us to perform a task in multiple ways. Let’s break the word Polymorphism and see it, ‘Poly’ means ‘Many’ and ‘Morphos’ means ‘Shapes’.

    Let’s see an example. Assume we have four students and we asked them to draw a shape. All the four may draw different shapes like Circle, Triangle, and Rectangle.

    Polymorphism In Java

    We will see detailed explanation with some example programs about Polymorphism in the post related to Polymorphism.

    There are two types of Polymorphism in Java

    1. Compile time polymorphism (Static binding) – Method overloading
    2. Runtime polymorphism (Dynamic binding) – Method overriding

    We can perform polymorphism by ‘Method Overloading’ and ‘Method Overriding’

    I recommend you to go through the following posts.

    Method Overloading: (Static Polymorphism/Compile time polymorphism)

    Method Overriding: (Dynamic Polymorphism/Run time polymorphism)

    Let’s see some practical examples of both compile time polymorphism and run time polymorphism.

    Compile Time Polymorphism:

    Output:

    Run Time Polymorphism:

    Output:

    Must Read: Java Tutorial

    Sharing is caring.

    Share on facebook
    Facebook
    Share on twitter
    Twitter
    Share on linkedin
    LinkedIn

    Like This Post?

    We have a lot more where that came from?

    We only send really good stuff occasionally, promise.

    Rajkumar SM

    Leave a Comment

    Your email address will not be published. Required fields are marked *

    Share on facebook
    Share on google
    Share on twitter
    Share on linkedin
    Share on whatsapp

    Recent Posts:

    Scroll to Top
    API Testing eBook

    DOWNLOAD FOR FREE