 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Can I overload private methods in Java?
Overloading is a one of the mechanisms to achieve polymorphism where, a class contains two methods with same name and different parameters.
Whenever you call this method the method body will be bound with the method call based on the parameters.
Overloading private methods
Yes, we can overload private methods in Java but, you can access these from the same class.
Example
public class Calculator {    private int addition(int a , int b){       int result = a+b;       return result;    }    private int addition(int a , int b, int c){       int result = a+b+c;       return result;    }    public static void main(String args[]){       Calculator obj = new Calculator();       System.out.println(obj.addition(12, 13));       System.out.println(obj.addition(12, 13, 15));    } } Output
25 40
Advertisements
 