This repository has been archived by the owner on Mar 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
inher2.java
52 lines (51 loc) · 1.49 KB
/
inher2.java
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
45
46
47
48
49
50
51
52
class Member{
int age, sal;
String name, address, phone;
void printSalary(){
System.out.println("Salary is "+sal);
}
}
class Employee extends Member{
String specialization;
void printdata(){
System.out.println("Name is "+name);
System.out.println("Address is "+address);
System.out.println("Phone is "+phone);
System.out.println("Age is "+age);
System.out.println("Specialization is "+specialization);
printSalary();
}
}
class Manager extends Member{
String Department;
void printdata(){
System.out.println("Name is "+name);
System.out.println("Address is "+address);
System.out.println("Phone is "+phone);
System.out.println("Age is "+age);
System.out.println("Department is "+Department);
printSalary();
}
}
class inher2{
public static void main(String[] args){
System.out.println("Employee Details:");
Employee e1 = new Employee();
e1.name = "Dhyey";
e1.address = "Rajkot";
e1.phone = "5555333399";
e1.age = 21;
e1.specialization = "CSE";
e1.sal = 100000;
e1.printdata();
System.out.println("Manager Details:");
Manager m1 = new Manager();
m1.name = "John";
m1.address = "Bangalore";
m1.phone = "9323532115";
m1.age = 25;
m1.Department = "IT";
m1.sal = 15000;
m1.printdata();
}
}