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

Java · Theory

Method Overloading in Java

← All stacks

Theory

35/270

Method Overloading in Java

Overloading = same method name in the same class with different parameter lists. Change the number or types: add(int, int) vs add(double, double). The compiler picks the match from the arguments you pass.

Return type alone does not create a valid overload. That is the trap. Overloading is handy for convenience APIs — print with many input shapes.

Interview line — same name, different params, compile-time. Return type alone is not enough.

Let's take this on the board with one tiny Main class — no extra files. Method Overloading 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 Method Overloading.

Exam tip

Stress: 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));
  }
}

Method Overloading in Java — compiler picks the matching add based on argument types.

Short notes

  • DefOverloading = same name, different parameter lists, same class.
  • RuleDecided at compile time from the arguments.
  • TrapDifferent return type alone is not overloading.
  • UseConvenience APIs like print with many shapes.

Questions

1

What is overloading?

2

When is overloading decided?

3

Can return type alone overload?

Previous← Aggregation in JavaNextMethod Overriding 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.