forked from Shubhamlmp/Programming-Practice
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPersonInheritance.java
More file actions
44 lines (32 loc) · 759 Bytes
/
PersonInheritance.java
File metadata and controls
44 lines (32 loc) · 759 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
40
41
42
43
44
class Teachers extends PersonInheritance{
}
class Students extends PersonInheritance{
}
class Staffs extends PersonInheritance{
}
public class PersonInheritance {
String name;
int phone;
public void showaddress() {
System.out.println("Name: "+name);
System.out.println("Phone: "+phone);
}
public static void main(String[] args) {
PersonInheritance t1=new PersonInheritance();
t1.name="Aliya";
t1.phone=123;
t1.showaddress();
Teachers t2= new Teachers();
t2.name="abid";
t2.phone=456;
t2.showaddress();
Staffs s1= new Staffs();
s1.name="goutham kk";
s1.phone=789;
s1.showaddress();
Students s2=new Students();
s2.name="rishiiiii";
s2.phone=123;
s2.showaddress();
}
}