Polymorphism occurs when the methods of the child class.

A. Override the parent class methods but maintain the implementation
B. Maintain the same return type and arguments as the parent class, but implement it differently
C. Have different return types and arguments than the parent class
D. Are virtual
View Answer

B. Maintain the same return type and arguments as the parent class, but implement it differently

Explanation

Polymorphism occurs when the methods of the child class maintain the same return type and arguments as the parent class but implement it differently. The type declared in the child’s method must match the parent’s return type or have one of its own that can be promoted to that parent class type. To demonstrate this concept, let’s build a simple calculator with an additional method. We’ll call our calculator class Parent Class and have it extend Object since it doesn’t inherit from any other classes yet.

The following is a sample code for polymorphism in Java.

public class Shape {

public static void main(String