-
Notifications
You must be signed in to change notification settings - Fork 0
/
Q_35.java
95 lines (79 loc) · 1.85 KB
/
Q_35.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package New;
import java.util.Scanner;
class Emp{
Scanner sc=new Scanner(System.in);
String fname,lname,desg,dep;
void getFirstName(){
System.out.println("Enter Firstname of an Employee");
fname=sc.nextLine();
}
void getLastName() {
System.out.println("Enter Lastname of an Employee");
lname=sc.nextLine();
}
}
class ContractEmployee extends Emp{
void displayFullName() {
System.out.println("FirstName="+fname);
System.out.println("LAstName="+lname);
}
void getDepartment() {
System.out.println("Enter department of Contract Employee");
dep=sc.nextLine();
}
void getDesignation() {
System.out.println("Enter designation of Contract Employee");
desg=sc.nextLine();
}
}
class RegularEmployee extends Emp{
void displayFullName() {
System.out.println(fname+" "+lname);
}
void getDepartment() {
System.out.println("Enter department of Regular Employee");
dep=sc.nextLine();
}
void getDesignation() {
System.out.println("Enter designation of Regular Employee");
desg=sc.nextLine();
}
}
public class Q_35 {
public static void main(String[] args) {
// TODO Auto-generated method stub
ContractEmployee obj1=new ContractEmployee();
RegularEmployee obj2=new RegularEmployee();
obj1.getFirstName();
obj1.getLastName();
obj2.getFirstName();
obj2.getLastName();
obj1.displayFullName();
obj2.displayFullName();
obj1.getDepartment();
obj2.getDepartment();
obj1.getDesignation();
obj2.getDesignation();
}
}
/*Output
Enter Firstname of an Employee
Manisha
Enter Lastname of an Employee
Sahu
Enter Firstname of an Employee
Sonia
Enter Lastname of an Employee
Goplani
FirstName=Manisha
LAstName=Sahu
Sonia Goplani
Enter department of Contract Employee
Mtech
Enter department of Regular Employee
MCA
Enter designation of Contract Employee
Student
Enter designation of Regular Employee
Working Professional
*/