Let's learn java programming language with easy steps

Sunday, 29 January 2017

Polymorphism in java

 Polymorphism

Polymorphism In Java

Polymorphism is derived from 2 greek words 'poly' and 'morphs'. The word poly means many and morphs mean behavior or form.

                                          Poly + Morphs   
                                             ↓               ↓              

                                          many    behavior or form = many behavior

Polymorphism in java is an oops concept, Whenever an object producing different-different behavior in different-different circumstances is called polymorphism in java.

Polymorphism is always achieved via behavior(member function) of an object. Properties(data member) of an object do not play any role in case of polymorphism. Polymorphism can be defined in other words "one name many forms".


Examples of polymorphism related to real life

(1) Related to person
  • Suppose you are in a classroom that time you behave like a student.
  • When you at your home at that time you behave like a son or daughter or brother.
  • When you are in a market, you behave like a customer.

(2) Related to product
  • Suppose Air Conditioner producing hot air in winter and cold air in summer.
So there is one name but producing different -different behavior in different circumstances.


Types of polymorphism in java, these are

  • Compile time or static polymorphism
  • Run time or dynamic polymorphism


Compile-time polymorphism

Method overloading (function overloading) and operator overloading both are compile time polymorphism. Method overloading(function overloading) or static binding(early binding ) is also known as compile time polymorphism in java.

"Whenever an object is bound with their functionality at compile time, this known as compile time polymorphism".


👉: Java does not support compile-time or static polymorphism. Java supports only dynamic polymorphism or run-time polymorphism.



Runtime polymorphism

Method overriding (function overriding) or Dynamic Binding(late binding) is known as runtime polymorphism in java. In java polymorphism principal is implemented with method overriding concept.

"Whenever an object is bound with their functionality at run-time, this known as run time polymorphism".


👉: Without inheritance concept method overriding is not possible in java So we will learn method overriding or dynamic binding after inheritance concept of oops.



Difference between Compile Time and Run Time Polymorphism  in Java

Compile-Time Polymorphism
  • In Compile Time polymorphism, call is resolved by the compiler.
  • Compile-Time polymorphism is also known as static binding, early binding, and overloading as well.
  • Overloading is compile time polymorphism, where more than one methods share the same name with different parameter or arguments.
  • Compile Time polymorphism is achieved by function overloading or method overloading and operator overloading.
  • It provides fast execution because known early at compile time.
  • Compile time polymorphism is less flexible as all thing executes at compile time.
Run-Time Polymorphism
  • In Run-Time polymorphism, call is not resolved by the compiler.
  • Run-Time polymorphism is also known as dynamic binding, late binding, and overriding as well.
  • Overriding is runtime polymorphism having the same method with same parameters or arguments but associated in a class and its subclass.
  • It is achieved by method overriding.
  • It provides slow execution as compared to early binding because it is known as run time.
  • Runtime polymorphism is more flexible because all thing executes at runtime.

Read More:


Share:

22 comments:

  1. Java is a high level, robust, secured and object-oriented programming language.The latest release of the Java Standard Edition is Java SE 8. Your post about polymorphism in java is really very informative. Wish to learn Java Training in Velachery enroll you in Login For Excellence

    ReplyDelete
  2. Nice blog..! I really loved reading through this article... Thanks for sharing such an amazing post with us and keep blogging...
    ios app development course

    ReplyDelete
  3. I just needed to record a speedy word to express profound gratitude to you for those magnificent tips and clues you are appearing on this site.
    http://www.traininginmarathahalli.in/core-java-training-in-bangalore/

    ReplyDelete
  4. Very Informative and insightful blog! This is so important to know about polymorphism in java I have been looking for this concept from many days and here i have found it in detail. This is good for beginner to know about polymorphism. Thanks for sharing!

    ReplyDelete
  5. That is very interesting; you are a very skilled blogger. I have shared your website in my social networks! A very nice guide. I will definitely follow these tips. Thank you for sharing such detailed article. Java Training in Chennai
    Java Training Institute in Chennai

    ReplyDelete
  6. Really awesome blog. Your blog is really useful for me. Thanks for sharing this informative blog. Keep update your blog...Java Training in Chennai
    Java Training Institute in Chennai

    ReplyDelete
  7. That is very interesting; you are a very skilled blogger. I have shared your website in my social networks! A very nice guide. I will definitely follow these tips. Thank you for sharing such detailed article. Java Training in Chennai
    Java Training Institute in Chennai

    ReplyDelete
  8. I believe there are many more pleasurable opportunities ahead for
    individuals that looked at your site.


    java training in chennai


    java training in bangalore

    ReplyDelete
  9. Nice blog..! I really loved reading through this article... Thanks for sharing such an amazing post with us and keep blogging...http://www.greenstechnologys.com/java-training-course-content.html

    ReplyDelete
  10. Great! Keep sharing such useful information. I think this is just the beginning & I'm looking forward to more meaningful blogs from you.

    white label website builder

    ReplyDelete
  11. Thanks a lot very much for the high quality and results-oriented help. I won’t think twice to endorse your blog post to anybody who wants and needs support about this area.
    Java Training in Chennai
    Java Training Institute in Chennai

    ReplyDelete
  12. I feel really happy to have seen your webpage and look forward to so many more entertaining times reading here. Thanks once more for all the details.
    Best Java Training Institute Chennai

    ReplyDelete
  13. You truly did more than visitors’ expectations. Thank you for rendering these helpful, trusted, edifying and also cool thoughts on the topic to Kate.
    Best Java Training Institute Chennai

    ReplyDelete
  14. Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here.

    Best RPA Training in Bangalore

    ReplyDelete
  15. Ciitnoida provides Core and java training institute in

    noida
    . We have a team of experienced Java professionals who help our students learn Java with the help of Live Base Projects. The object-

    oriented, java training in noida , class-based build

    of Java has made it one of most popular programming languages and the demand of professionals with certification in Advance Java training is at an

    all-time high not just in India but foreign countries too.

    By helping our students understand the fundamentals and Advance concepts of Java, we prepare them for a successful programming career. With over 13

    years of sound experience, we have successfully trained hundreds of students in Noida and have been able to turn ourselves into an institute for best

    Java training in Noida.

    java training institute in noida
    java training in noida

    ReplyDelete

  16. Pretty blog, so many ideas in a single site, thanks for the informative article, keep updating more article.
    Webdesining course in chennai

    ReplyDelete
  17. I simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site.
    Java training institute in chennai

    ReplyDelete
  18. Thanks for sharing information with clear explanation. This is really awesome to understand.

    Thanks,
    Java Training in Chennai | Java Course in Chennai

    ReplyDelete
  19. The article is too good to learn in depth. Thanks for sharinng such useful information.

    Java training in Chennai

    ReplyDelete
  20. I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
    Click here:
    Online training in USA

    ReplyDelete

Facebook Page Likes

Follow javatutorial95 on Google+

Follow javatutorial95 on twitter

Popular Posts

Get Updates By Email

Link

Translate