Polymorphism
Polymorphism is derived from 2 greek words 'poly' and 'morphs'. The word poly means many and morphs mean behavior or form.
Poly + Morphs
↓ ↓
Polymorphism in java is an oops concept, Whenever an object producing different-different behavior in different-different circumstances is called polymorphism in java.
many behavior or form = many behavior
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.
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:
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
ReplyDeleteGreat Article android based projects
DeleteJava Training in Chennai
Project Center in Chennai
Java Training in Chennai
projects for cse
The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training
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.
ReplyDeletehttp://www.traininginmarathahalli.in/core-java-training-in-bangalore/
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!
ReplyDeleteThat 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
ReplyDeleteJava Training Institute in Chennai
Really awesome blog. Your blog is really useful for me. Thanks for sharing this informative blog. Keep update your blog...Java Training in Chennai
ReplyDeleteJava Training Institute in Chennai
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
ReplyDeleteGreat! Keep sharing such useful information. I think this is just the beginning & I'm looking forward to more meaningful blogs from you.
ReplyDeletewhite label website builder
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.
ReplyDeleteJava Training in Chennai
Java Training Institute in Chennai
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.
ReplyDeleteBest Java Training Institute Chennai
You truly did more than visitors’ expectations. Thank you for rendering these helpful, trusted, edifying and also cool thoughts on the topic to Kate.
ReplyDeleteBest Java Training Institute Chennai
Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here.
ReplyDeleteBest RPA Training in Bangalore
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.
ReplyDeleteJava training institute in chennai
Thanks for sharing information with clear explanation. This is really awesome to understand.
ReplyDeleteThanks,
Java Training in Chennai | Java Course in Chennai
The article is too good to learn in depth. Thanks for sharinng such useful information.
ReplyDeleteJava training in Chennai
I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
ReplyDeleteClick here:
Online training in USA
Thanks admin for spending your valuable time to write an excellent article
ReplyDeleteSelenium training in chennai
Selenium training institute in Chennai
iOS Course Chennai
French Classes in Chennai
Big Data Training in Chennai
PHP Course Chennai
php course
Thanks for sharing information with clear explanation. This is really awesome to understand.
ReplyDeleteJava training in Chennai |
Tally training in Chennai"
Amazing post thanks for sharing
ReplyDeletebest salesforce training in chennai
ReplyDeleteThank you for sharing such great information very useful to us.
Java Training in Noida
The strategy you have posted on this technology helped me to get into the next level and had lot of information in it. The angular js programming language is very popular which are most widely used.
ReplyDeleteDot Net Training in Chennai | Dot Net Training in anna nagar | Dot Net Training in omr | Dot Net Training in porur | Dot Net Training in tambaram | Dot Net Training in velachery
Fantastic blog with excellent information thanks for sharing found very useful thank you.
ReplyDeletetypeerror nonetype object is not subscriptable
Thanks for sharing such a helpful, and understandable blog. I really enjoyed reading it.
ReplyDeleteRobots for kids
Robotic Online Classes
Robotics School Projects
Programming Courses Malaysia
Coding courses
Coding Academy
coding robots for kids
Coding classes for kids
Coding For Kids
Nice Post. Also check linux online training
ReplyDeletemulesoft online training
I think this is one of the best blog for me because this is really helpful for me. Thanks for sharing this valuable information
ReplyDeleteinternship meaning | internship meaning in tamil | internship work from home | internship certificate format | internship for students | internship letter | Internship completion certificate | internship program | internship certificate online | internship graphic design
Thanks for the blog article.Much thanks again. Fantastic.
ReplyDeletecore java online course
core java course
Thank you for the blog
ReplyDelete