Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Polymorphism Java

    • 0
    • 1
    • 1
    • 2
    • 0
    • 0
    • 0
    • 0
    • 298
    Comment on it

    Polymorphism in Java

    OOP's a very important jargon in the programming world, and many of us are familiar with this word, Object oriented Programming. Polymorphism is a main pillar of OOP,s by definition it is the ability of an object to take on many forms.

    But the main Question is what these lines really means "the ability of an object to take on many forms". So to clear this fog from my fellow programmers . Polymorphism can easily be understood with the help of the following example

    Suppose there is a super class Shape and to sub classes Circle and Rectangle, both Rectangle and Circle extends Shape.

    so the magic of polymorphism is "the reference of the parent class (Shape) is used to refer to a child class object

         Shape s1=new Rectangle(1, 3);
         Shape s2=new Circle(2);
         Object o1=new Circle(4);
         Object o1=new Rectangle(4, 3);
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: