Q1. Write an application that performs each of the followingtasks:
a) Specify that class “Pieceworker†inherits from classEmployee.
b) Create instance variables “Firstname†and “ID†in superclassand a toString to display.
c) Add “branch†and toString in PieceWorker.
d) Show overriding to display the variables of the subclass.
Q2 Draw an inheritance hierarchy for students at auniversity.
- Use Student as the superclass of the hierarchy, and then extendStudent with classes Undergraduate Student and GraduateStudent.
- Continue to extend the hierarchy as deep (i.e., as many levels)as possible. For example, freshman, sophomore, Junior and Seniormight extend undergraduate Student, and Doctoral Student andMasters Student might be subclasses of graduate Student.
- After drawing the hierarchy, discuss the relationships thatexist between the classes.
- Write a program that illustrates the above idea ofhierarchy.