top of page

Polymorphism concept to the beginners.

  • Writer: khyati sehgal
    khyati sehgal
  • Jul 24, 2014
  • 1 min read

The most common question asked in interviews is the OOPS concept details, meaning, and example. Today, I will be sharing some real-life examples of Polymorphism and in my coming blogs, I will be sharing some real-time examples of other OOPS concepts.

This is basically a concept by which one API once is written can be used by many other similar classes. We will see how we can implement and use polymorphism in Java.

Java is a language that supports the flexibility of code to a good extend. Here code written in a single class can be used by other classes also.  Poly- means many and morph- means form. So the ability of classes to have different forms is known as Polymorphism.


For example, Shapes is a class, and square, circles are all shapes which they can acquire. So a method written in shapes can be used by its forms like this:

Shapes

2. Musician – Different forms of musicians are there who sings Hollywood songs, Metal, Blues, Soft music, Rock Music, etc. So we can divide on the basis of singers-genres.


Musician

3. Numbers- Mathematics numbers are of different types like Rational, Integer, Big decimal, Float, etc. And they further can be used to apply other mathematical operations.


MathematicalNumbers

4. Cars can be of different types- Racing cars, 2 seater cars, 6 seater cars, 4 seater cars. Also can be classified on the basis of doors like cars having 2 doors, 4 doors, 6 doors, etc. It can also be categorized on the basis of brands like BMW, Audi, Merc, Maruti, etc.


Car

Recent Posts

See All

Comments


bottom of page