Domanda di colloquio di Revature

Explain method overloading and method overriding. What are the differences?

Risposte di colloquio

Anonimo

7 mag 2020

Method overloading is when you have 2 or more methods in the same class with the same name but different parameters. Overriding is when the child class implements a method differently from its parent class.

1

Anonimo

17 nov 2020

Method Overloading is when a " method" different forms. more precisely when two or more method have the same name but a different number of parameters and/or data types For Example, take a method name "addNumber" can accept two int type parameter or two float type parameters. addNumber(int a , int b) addNumber(float a, float b) Method Overriding is when a child class overrides the parent class method and implements its own instruction. Method Override requires inheritance while method loading happens in the same class.