Explain how to implement polymorphism in Java. Capacity of a method to do different things based on the object that it is acting upon is called as polymorphism. Poly means multiple and morph means change which means a method that provides multiple outputs with different input is said to follow polymorphism principle.
Types of polymorphism - Polymorphism through overloading - Polymorphism through inheritance or interface How can you achieve Multiple Inheritance in Java? The feature of multiple inheritance in java is eliminated. To inherit a class is to be extended by another class to reuse the class elements and extend itself. A class can implement multiple interfaces, in which all the methods of interfaces must be overridden. Where as in inheritance concept, all the methods, if needed, can be invoked directly and need not be overridden. This is the reason why java eliminates the multiple inheritance feature. Of course, the static final members can be reused.
|