The correct answer is:
(b) Function overloading
Explanation: Function overloading in Java refers to the ability to define multiple methods with the same name in a class, but with different parameter lists. The methods must differ in the number or types of parameters (or both), which allows the compiler to distinguish between the different methods based on the arguments passed when calling them.
For example:
In this case, the method display
is overloaded: one version takes an int
, and another takes a String
.
- Function overriding (option a) refers to defining a method in a subclass with the same name and parameters as a method in its superclass, allowing the subclass to provide its own implementation.