Which of the following is true about method overloading?

Java MCQ: Which of the following is true about method overloading?

a) Methods with the same name and parameters
b) Methods with the same name but different parameters
c) Methods with different names
d) Methods with the same return type

Answer:

b) Methods with the same name but different parameters

Explanation:

Method overloading in Java occurs when two or more methods in the same class have the same name but different parameters (different type, number, or both). This allows for multiple methods to handle different types of inputs using the same method name.

Understanding method overloading is essential for writing flexible and reusable code in Java, enabling methods to operate on different types or quantities of data.

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