-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOverloadDemo.java
More file actions
39 lines (36 loc) · 865 Bytes
/
OverloadDemo.java
File metadata and controls
39 lines (36 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
class OverLoad
{
void add()
{
int a=100,b=200;
System.out.println(" No arguments");
System.out.println("Addition is :"+(a+b));
}
void add(int a, int b)
{
System.out.println(" a is integer b is integer");
System.out.println("Addition is :"+(a+b));
}
void add(double a, double b)
{
System.out.println(" a is double b is double");
System.out.println("Addition is :"+(a+b));
}
double add(double a, int b)
{
System.out.println("a is double b is int return type is double");
double c=a+b;
return c;
}
}
public class OverloadDemo {
public static void main(String[] args) {
// TODO Auto-generated method stub
OverLoad o=new OverLoad();
o.add(10.5, 20.5);
o.add();
o.add(10, 20);
double result=o.add(10.5,20);
System.out.println("Result is :"+result);
}
}