Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Write a java Program which explain the possible three ways of method overloading.
- class Ex3 //Ex3 is Java Program Name
- {
- public void add(int a, int b)
- {
- System.out.println(a+b);
- }
- public void add(int a, int b, int c)
- {
- System.out.println(a+b+c);
- }
- public void add(int a, double b)
- {
- System.out.println(a+b);
- }
- public void add(double a, int b)
- {
- System.out.println(a+b);
- }
- public static void main(String a[])
- {
- Ex3 obj = new Ex3();
- obj.add(1,2);
- obj.add(1,2,3);
- obj.add(1,1.2);
- obj.add(1.2,1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement