Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c1ead6b

Browse files
authoredApr 29, 2021
Create Overloading.java
1 parent 9aa1b69 commit c1ead6b

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed
 

‎Overloading.java

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
//Overloading
2+
//changing number of arguments
3+
4+
class Over
5+
{
6+
static int add(int a,int b)
7+
{
8+
return a+b;
9+
}
10+
static int add(int a,int b,int c)
11+
{
12+
return a+b+c;
13+
}
14+
}
15+
class TestOverloading
16+
{
17+
public static void main(String[] args)
18+
{
19+
System.out.println(Over.add(10,10));
20+
System.out.println(Over.add(20,10,30));
21+
}
22+
}
23+
24+
//changing data type of arguments
25+
26+
// class Over
27+
// {
28+
// static int add(int a,int b)
29+
// {
30+
// return a+b;
31+
// }
32+
// static int add(int a,int b,int c)
33+
// {
34+
// return a+b+c;
35+
// }
36+
// }
37+
// class TestOverloading
38+
// {
39+
// public static void main(String[] args)
40+
// {
41+
// System.out.println(Over.add(10,10));
42+
// System.out.println(Over.add(20,10,30));
43+
// }
44+
// }
45+
46+
47+
class Adder
48+
{
49+
static int sum(int a, int b)
50+
{
51+
return a+b;
52+
}
53+
static double sum(double a, double b)
54+
{
55+
return a+b;
56+
}
57+
}
58+
class TestOverloading1
59+
{
60+
public static void main(String[] args)
61+
{
62+
System.out.println(Adder.sum(10,40));
63+
System.out.println(Adder.sum(16.7,18.4));
64+
}
65+
}
66+

0 commit comments

Comments
 (0)
Please sign in to comment.