Overloading VS Overriding

  • Overloading is about same function have different signatures.

  • Overriding is about same function, same signature but different classes connected through inheritance.

  • Overloading is an example of compiler time polymorphism and overriding is an example of run time polymorphism.

overloading

e.g.1

//no exception. String is subclass of Object
public method(String s){...}
public method(Object o){...}

e.g.2

// no exception
public method(Sting s){...}
public method(Object o){...}
public method(Integer i){...}

e.g.3 to be continue...

null????

Override

polymorphism

Last updated

Was this helpful?