-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinherit.java
More file actions
61 lines (58 loc) · 1.17 KB
/
inherit.java
File metadata and controls
61 lines (58 loc) · 1.17 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
import java.util.Scanner;
class Employee
{
String name;
int age;
long phno;
String address;
int salary;
Employee(String name, int age, long phno, String address, int salary)
{
this.name=name;
this.age=age;
this.phno=phno;
this.address=address;
this.salary=salary;
}
void display()
{
System.out.println("Name:"+name);
System.out.println("Age"+age);
System.out.println("Phone Number:"+phno);
System.out.println("Address:"+address);
}
void print_Salary()
{
System.out.println("Salary of the employee:"+salary);
}
}
class Officer extends Employee
{
String specialization;
Officer(String name, int age, long phno, String address, int salary)
{
super(name, age, phno, address, salary);
System.out.println("\nDetails of officer");
display();
print_Salary();
}
}
class Manager extends Employee
{
String department;
Manager(String name, int age, long phno, String address, int salary)
{
super(name, age, phno, address, salary);
System.out.println("\nDetails of manager");
display();
print_Salary();
}
}
class inherit
{
public static void main(String args[])
{
Officer O1 = new Officer("Megha", 32, 949557667,"Mumbai",500000 );
Manager O2 = new Manager("Nanma", 32, 949554267,"Dehradun",2500000 );
}
}