AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
![]() This is necessary because the subclass may override some or all of the methods defined in the parent class. But after referring to the online blogs and websites I have found that Method Overloading is Static and Method Overriding is Dynamic polymorphism. The book mentions that Method Overloading and Method overriding both are types of Dynamic Polymorphism. What is the difference between Static & Dynamic. Polymorphism is a direct consequence of the 'is-a' relationship. In many cases, inheritance is used to represent 'has-a' or 'takes-functionality-from-a', and thats typically better done by composition. Its really, really easy to overuse inheritance and wind up with a mess. ![]() It can be achieved through method overriding. Public inheritance is a 'is-a' relationship, not a 'usually is-a'. ![]() ![]() With dynamic polymorphism, the Java Virtual Machine (JVM) handles the detection of the appropriate method to execute when a subclass is assigned to its parent form. I am learning JAVA from Core Java An Integrated Approach by Dr.R.Nageswara Rao. Dynamic polymorphism is also called as runtime polymorphism. Method Overloading demonstrates static polymorphism and Method Overriding is used in Dynamic Method Dispatch for implementation of Dynamic Polymorphism. ![]()
0 Comments
Read More
Leave a Reply. |