![]() ![]() Each subclass has its way of calculating area. Subclasses of “Shapes” can be “Triangle”, “circle”, “Rectangle”, etc. Polymorphism in Java ExampleĪ superclass named “Shapes” has a method called “area()”. So we have a standard method function that performs differently depending upon the organ of the body. Every organ has a different function to perform the heart is responsible for blood flow, the lungs for breathing, the brain for cognitive activity, and the kidneys for excretion. she performs other behaviors in different situations. A woman can be a mother, a daughter, a sister, and a friend, all at the same time, i.e. Java Algorithms Java Data Structures OOPs Concept JDBC In Java Java Basic Programs Java Real-Life Examples of PolymorphismĪn individual can have different relationships with different people. Polymorphism, therefore, is one of the most significant features of Object-Oriented Programming. So, polymorphism means innumerable forms. “Poly” means numerous, and “Morphs” means forms. The derivation of the word Polymorphism is from two different Greek words- poly and morphs. Thus, allowing us to achieve the same action in many different ways. Polymorphism in Java allows us to use these inherited properties to perform different tasks. Java Inheritance lets one class acquire the properties and attributes of another class. Inheritance is a powerful feature in Java. Polymorphism occurs when there is inheritance, i.e., many classes are related. Since Java supports polymorphism, it is an Object-Oriented Language. ![]() ![]() So, languages that do not support polymorphism are not ‘Object-Oriented Languages’, but ‘Object-Based Languages’. Polymorphism in Java is the task that performs a single action in different ways.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |