-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHuman.java
More file actions
34 lines (29 loc) · 973 Bytes
/
Human.java
File metadata and controls
34 lines (29 loc) · 973 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
package inheritance;
public class Human {
int id = 1;
String name = "Rupali";
String address = "Pune";
double salary = 50000;
}
class Engineer extends Human{
String branch = "Computer Science";
}
class Doctor extends Human{
String specialization = "MD";
}
class HumanImpl {
public static void main(String[] args) {
Engineer engineer = new Engineer();
System.out.println("Id "+engineer.id);
System.out.println("Name "+engineer.name);
System.out.println("Address "+engineer.address);
System.out.println("Salary "+engineer.salary);
System.out.println("Branch "+engineer.branch);
Doctor doctor = new Doctor();
System.out.println("Id "+doctor.id);
System.out.println("Name "+doctor.name);
System.out.println("Address "+doctor.address);
System.out.println("Salary "+doctor.salary);
System.out.println("Specialization "+doctor.specialization);
}
}