Skip to content

Commit 4de6353

Browse files
authored
Create Overloading in java
1 parent 8c2de10 commit 4de6353

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

Overloading in java

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.company;
2+
3+
class i1
4+
{
5+
void hello(String s)
6+
{
7+
System.out.println(s);
8+
}
9+
}
10+
11+
class j1 extends i1{
12+
void hello(String s)
13+
{
14+
super.hello(s);
15+
System.out.println(s);
16+
}
17+
}
18+
19+
class k1 extends j1{
20+
void hello(String s)
21+
{
22+
super.hello(s);
23+
System.out.println(s);
24+
}
25+
}
26+
27+
public class overload {
28+
29+
public static void main(String[] args)
30+
{
31+
//referance and instace both are same i1
32+
33+
i1 obj1=new i1();
34+
// obj1.hello("vaghela ajitkumar");
35+
36+
//object same just change the instance is j1
37+
38+
//obj1=new j1();
39+
// obj1.hello("vaghela ajitkumar");
40+
41+
//object same just change the instance is k1
42+
43+
obj1=new k1();
44+
obj1.hello("goverment engineering collage rajkot");
45+
46+
47+
}
48+
}

0 commit comments

Comments
 (0)