Type Here to Get Search Results !

What is the difference between "method overriding" and "method overloading"?

0

 What is the difference between "method overriding" and "method overloading"?

A) Overriding changes the method signature, while overloading does not.
B) Overriding is related to subclasses, while overloading occurs within the same class.
C) Overloading allows for different return types, while overriding does not.
D) There is no difference; they are the same.

Answer: B) Overriding is related to subclasses, while overloading occurs within the same class.

Explanation: Method overriding occurs when a subclass provides a specific implementation for a method already defined in its superclass. In contrast, method overloading refers to defining multiple methods with the same name in the same class but with different parameter lists. This distinction is essential for understanding how polymorphism works in OOP.

Post a Comment

0 Comments