How toc create a class named Employee with name and salary. Make a class Manager inherit from Employee with an instance field named department. Supply a method toString() that prints the manager’s name, department and salary. Make another class named Director which inherits from Manager that has an instance field named carAllowanceAmount. Supply the toString() method for Director that prints all of its instance variables. Also, write a program name TestQ3 that instantiates an object of each of these classes and invokes the toString() method of each of these object.
(Note: all instance variables must be assigned with private accessibility and methods with public accessibility)
how to use toString?
View All Comments