Which of the following best describes polymorphism in Java?

Java MCQ: Which of the following best describes polymorphism in Java?

a) Polymorphism allows methods to have the same name but different parameter lists
b) Polymorphism allows an object to take on many forms
c) Polymorphism is implemented using the ‘extends’ keyword
d) Both a and b

Answer:

d) Both a and b

Explanation:

Polymorphism in Java is a core concept of object-oriented programming that allows objects to be treated as instances of their parent class. This means that a single function or method can operate on different types of objects, allowing for dynamic method invocation.

There are two types of polymorphism in Java: compile-time (method overloading) and runtime (method overriding). Method overloading allows multiple methods with the same name but different parameter lists within the same class. Method overriding, on the other hand, allows a subclass to provide a specific implementation of a method already defined in its superclass.

Polymorphism promotes flexibility and reusability in code by allowing a general interface to interact with a wide variety of objects in a consistent manner.

Reference links:

https://www.rameshfadatare.com/learn-java-programming/
https://www.javaguides.net/p/java-tutorial-learn-java-programming.html

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top