67.2k views
4 votes
For questions 19 - 21, assume that Student, Employee and Retired are all subclasses of Person, and all four classes have different implementations of the method getMoney. Consider the following code where ... are the required parameters for the constructors:

Person p = new Person(...);
int m1 = p.getMoney( ); // assignment 1
p = new Student(...);
int m2 = p.getMoney( ); // assignment 2
if (m2 < 100000) p = new Employee(...);
else if (m1 > 50000) p = new Retired(...);
int m3 = p.getMoney( ); // assignment 3

The reference to getMoney( ) in assignment 1 is to the class

Person
Student
Employee
Retired
this cannot be determined by examining the code

1 Answer

3 votes

Answer:

Person

Step-by-step explanation:

At

Person p = new Person(...);

int m1 = p.getMoney( ); // assignment 1

Person class which is base class for all sub class (Student, Employee and Retired ) creates an object which referenced is stored in p variable, and getMoney() is method which refereed Person's getMoney() method, so Person is the answer of above question

User Tinkerr
by
5.6k points