Java achieves Run Time Polymorphism in many ways, one of the ways is method overriding. As a result, the same method will be used in different conditions performing different operations. Method Overriding: If a superclass and a subclass consist of the same method, then method overriding refers to the process of overriding the method in the superclass by the method in the subclass. Polymorphism in Java can be achieved through three methods: Read more on various OOPs concepts and examples. You can also consider doing our Java Bootcamp course from upGrad to upskill your career. The ability of a class to provide different implementations of a method depends on the type of object that is passed to the method. This implies that an entity has the characteristics to operate differently according to the scenarios. One of the most common uses of polymorphism in Object Oriented Programming is when a parent class reference is used to refer to a child class object. That is, an entity can perform different operations in different scenarios. Different types of polymorphism in Java helps to mold various types of data. Polymorphism in Java reduces coupling and increases the readability of a code as well. Because of polymorphism, the reusability of a code can be done. This implies that polymorphism facilitates a single action to be performed in multiple ways. An object is able to mold itself into various forms through polymorphism. Like inheritance that inherits methods and attributes from a different class, polymorphism applies those methods and performs different tasks. Check out our free courses to get an edge over the competition.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |