- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is Overloading in Java?
When a class has two or more methods by the same name but different parameters, at the time of calling based on the parameters passed respective method is called (or respective method body will be bonded with the calling line dynamically). This mechanism is known as method overloading.
Example
public class Sample{ public static void add(int a, int b){ System.out.println(a+b); } public static void add(int a, int b, int c){ System.out.println(a+b+c); } public static void main(String args[]){ Sample obj = new Sample(); obj.add(20, 40); obj.add(40, 50, 60); } }
Output
60 150
- Related Articles
- What is method overloading in Java?
- What is constructor overloading in Java?
- What is overriding and overloading under polymorphism in java?
- What is overloading in C#?
- Constructor overloading in Java
- Method overloading in Java
- Overloading in java programming
- What is overloading? What happens if we overload a main method in java?
- What is function overloading in JavaScript?
- What is method overloading in C#?
- What is method overloading in PHP?
- What is the difference between method overloading and method hiding in Java?
- What is the difference between method overloading and method overriding in Java?
- Constructor Overloading In Java programming
- Using Method Overloading in Java

Advertisements