-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathInheritenceEG.java
More file actions
74 lines (66 loc) · 1.87 KB
/
InheritenceEG.java
File metadata and controls
74 lines (66 loc) · 1.87 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import java.util.Scanner;
class Employeee
{
String name,address;
int number,age,salary;
public void printsalary()
{
System.out.println("Salary= "+salary);
}
public void display()
{
System.out.println("Name= "+name);
System.out.println("Address= "+address);
System.out.println("Number= "+number);
System.out.println("Age= "+age);
}
}
class Officer extends Employeee
{
String specialization;
}
class Manager extends Employeee
{
String department;
}
public class InheritenceEG
{
public static void main(String[] args)
{
Scanner S= new Scanner(System.in);
Officer O=new Officer();
Manager M=new Manager();
System.out.println("Enter the name of officer: ");
O.name=S.next();
System.out.println("Enter the address of officer: ");
O.address=S.next();
System.out.println("Enter the phone number of officer: ");
O.number=S.nextInt();
System.out.println("Enter the age of officer: ");
O.age=S.nextInt();
System.out.println("Enter the salary of officer: ");
O.salary=S.nextInt();
System.out.println("Enter the specialization of officer: ");
O.specialization=S.next();
System.out.println("Enter the name of manager: ");
M.name=S.next();
System.out.println("Enter the address of manager: ");
M.address=S.next();
System.out.println("Enter the phone number of manager: ");
M.number=S.nextInt();
System.out.println("Enter the age of manager: ");
M.age=S.nextInt();
System.out.println("Enter the salary of manager: ");
M.salary=S.nextInt();
System.out.println("Enter the department of manger: ");
M.department=S.next();
System.out.println("\t\tDETAILS OF OFFICER");
O.display();
O.printsalary();
System.out.println("Specialization= "+O.specialization);
System.out.println("\t\tDETAILS OF MANAGER");
M.display();
M.printsalary();
System.out.println("Department= "+M.department);
}
}