PGoCareerGoCareer prep tools
Home
LoginSign up
  • Java
  • Python
  • AI
  • React
  • Angular
  • PHP
  • Node.js
  • SQL
  • DSA
  • HTML
  • CSS
  • JS
  • Spring
  • ML
  • MongoDB

Java · Theory

Difference Between Method Overloading and Method Overriding in Java

← All stacks

Theory

68/270

Difference Between Method Overloading and Method Overriding in Java

Overloading: same name, different parameters, same class, compile time. Overriding: child rewrites parent method with the same signature, runtime. Return type alone cannot overload.

Show overloading: add(int,int) and add(double,double). Show overriding: Animal a = new Dog(); a.sound(); → Dog’s version. Use @Override.

Don’t mix the two words. Two timings, two examples.

Let's take this on the board with one tiny Main class — no extra files. Difference Between Method Overloading and Method Overriding in Java — compiler picks the matching add based on argument types. Start from main, go line by line, and stop at each print. That output is the proof for Difference Between Method Overloading and Method Overriding.

Exam tip

Two timings + two examples. Return type alone cannot overload.

Example

// Method overloading
public class Main {
  static int add(int a, int b) { return a + b; }
  static double add(double a, double b) { return a + b; }

  public static void main(String[] args) {
    System.out.println(add(2, 3));
    System.out.println(add(2.5, 3.5));
  }
}

Difference Between Method Overloading and Method Overriding in Java — compiler picks the matching add based on argument types.

Short notes

  • DefOverloading = different params, compile-time. Overriding = same signature in child, runtime.
  • RuleReturn type alone cannot overload. @Override for overriding.
  • RememberAnimal a = new Dog(); a.sound(); → Dog.
  • TrapMixing the two definitions.

Questions

1

When is overloading decided?

2

When is overriding decided?

Previous← Difference between Object and ClassNextDifference Between Class and Interface in Java →
P

GoCareerGo

Utilities · Preparation Hub · Resume · CV · Tools — one workspace.

Workspace

DashboardProfilePreparation HubResume builderCV builderCareer planning

PDF Tools

Merge PDFSplit PDFCompress PDFImage to PDFAll toolsJobs

Image & QR

Compress ImageResize ImageQR ScannerQR GeneratorBlogIT interview prep

Company

FAQFeedbackContactPrivacyTermsSitemap

© 2026 GoCareerGo. Keep moving forward.