Skip to content

Commit 0a614a4

Browse files
authored
Create PersonInheritance.java
1 parent 5d85db5 commit 0a614a4

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

PersonInheritance.java

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
class Teachers extends PersonInheritance{
2+
3+
}
4+
class Students extends PersonInheritance{
5+
6+
}
7+
class Staffs extends PersonInheritance{
8+
9+
}
10+
11+
12+
public class PersonInheritance {
13+
String name;
14+
int phone;
15+
16+
public void showaddress() {
17+
System.out.println("Name: "+name);
18+
System.out.println("Phone: "+phone);
19+
}
20+
21+
22+
public static void main(String[] args) {
23+
PersonInheritance t1=new PersonInheritance();
24+
t1.name="Aliya";
25+
t1.phone=123;
26+
t1.showaddress();
27+
28+
Teachers t2= new Teachers();
29+
t2.name="abid";
30+
t2.phone=456;
31+
t2.showaddress();
32+
33+
Staffs s1= new Staffs();
34+
s1.name="goutham kk";
35+
s1.phone=789;
36+
s1.showaddress();
37+
38+
Students s2=new Students();
39+
s2.name="rishiiiii";
40+
s2.phone=123;
41+
s2.showaddress();
42+
}
43+
44+
}

0 commit comments

Comments
 (0)