Question: 1. Design and declaration. All classes data fields should be private. (40%) a. Design a class named Person (5%) i. Person has a data field:
1. Design and declaration. All classes data fields should be private. (40%)
a. Design a class named Person (5%)
i. Person has a data field: name. Default: name is unknown,
ii. Person has a method printInfo() which will print all data fields.
iii. and its two subclasses named Student and Employee.
b. Design a class named Employee which is a subclass of Person. (5%)
i. Employee has a data field: salary. Default: salary is 0,
ii. Employee has a method printInfo()which will print all data fields( including data fields in super class) (Hint: use super keyword to get info from super class.)
c. Design a class named Faculty which is a subclass of Employee. (10%)
i. Faculty has a data field: dept. Default: dept is none,
ii. Faculty has a method printInfo()which will print all data fields( including data fields in super class)
d. Design a class named Student which is a subclass of Person. (10%)
i. Student has two data fields: age, default 0; email address, default: none
ii. Student has a method printInfo()which will print all data fields( including data fields in super class)
e. Implement necessary constructors, accessor and mutator methods for all the above classes.(10%)
2. Write a test program to create two Students and two Faculties, assign (NOT read from console) the following information, and invokes their printInfo methods. xxxx is your school ID. (10%)
A Student object name: unknown, age: -1, email: none
A Student object name: demo_s2, age: 23, email: xyz @ email
A Faculty object name: demo_f1, salary: -1, dept: none
A Faculty object name: demo_f2, salary: 10000, dept: CS
3. Your program output should look like below: (10%)
Student name: unknown, age: -1, Email: none
Student name: demo_s2, age: 23, Email: xyz@certain email
Faculty name: demo_f1, salary: -1, dept: none
Faculty name: demo_f2, salary: 10000, dept: CS
This should be coded in ONE java file.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
