-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathOverrideDemo.java
More file actions
76 lines (69 loc) · 2.16 KB
/
OverrideDemo.java
File metadata and controls
76 lines (69 loc) · 2.16 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
75
76
package chandana;
class Employee
{
int empID;
String name;
String phone;
double salary;
public Employee(int empID,String name,String phone,double salary)
{
this.empID=empID;
this.name=name;
this.phone=phone;
this.salary=salary;
}
public void displayDetails() {
System.out.println("Employee ID:"+empID);
System.out.println("Name:"+name);
System.out.println("Phone:"+phone);
System.out.println("Salary: $"+salary);
}
}
class Tester extends Employee
{
private int projectID;
private String projectName;
public Tester(int empID,String name,String phone,double salary,int projectID,String projectName)
{
super(empID,name,phone,salary);
this.projectID=projectID;
this.projectName=projectName;
}
public void displayDetails() {
super.displayDetails();
System.out.println("Project ID:"+projectID);
System.out.println("Project Nmae:"+projectName);
System.out.println("--------------------------------");
}
}
class Developer extends Employee
{
private String projectName;
public Developer(int empID,String name,String phone,double salary,String projectName)
{
super(empID,name,phone,salary);
this.projectName=projectName;
}
public void displayDetails()
{
super.displayDetails();
System.out.println("Project Nmae:"+projectName);
System.out.println("--------------------------------");
}
}
public class OverrideDemo {
public static void main(String[] args) {
Tester tester1=new Tester(1,"alice","1234567899",6000,101,"P-A");
Tester tester2=new Tester(2,"klice","1236567999",9000,102,"P-B");
Developer developer1=new Developer(3,"Charlie","4785248968",8000,"P-C");
Developer developer2=new Developer(4,"Chandu","4785948368",3000,"P-D");
System.out.println("tester1 Details: ");
tester1.displayDetails();
System.out.println("tester2 Details: ");
tester2.displayDetails();
System.out.println("Developer1 Details: ");
developer1.displayDetails();
System.out.println("Developer 2 Details: ");
developer2.displayDetails();
}
}