Java, Java Basics, Java Class, Java Object, Java Polymorphism, Object Oriented

Polymorphism concept to the beginners.

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

This is basically a concept by which one API once 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 which supports flexibility of code to a good extend. Here code written in single class can be used by other classes also.  Poly- means many and morph- means form . So an ability of classes to have different forms is known as Poly-morphism.

For  example: Shapes is a class , and square , circle 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 brand like BMW, Audi, Merc, Maruti, etc.

Car

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s