Differentiate between overloading and overriding in Java?

Some of the major differences are


  • Overloading can be in same class or in child class while overriding can only be in child class.
  • In case of overloading the signature of the methods must be different while in case of overriding the signature must be same.
  • Overloading is used to achieve the compile time polymorphism while overriding is used to achieve runtime polymorphism
  • In case of overloading the methods can have any scope while overriding we can increase the scope of overridden method but cannot decrease it


Comments

Popular posts from this blog

What is template?

Can we access private members of an instance?

What are wrapper classes in Java?