Question: 2. Class Butler and Baker both extend class Person (from question 1). Butler overrides method favoriteInt() to return its age. Baker does not override favoriteInt().
2. Class Butler and Baker both extend class Person (from question 1). Butler overrides method favoriteInt() to return its age. Baker does not override favoriteInt(). The constructors for both Butler and Baker take in their name and age and initialize their corresponding data fields to these values. You are given the following instances of Butler and Baker: Butler carson = new Butler("Mr. Carson", 62); // Mr. Carson's age is 62 Person gotoh = new Butler ("Gotoh", 38); // Gotoh's age is 38 Baker cm = new Baker("Cookie Monster", 14); // Cookie Monster's age is 14 (a) (4 points) Suppose we call carson.favoriteInt(). Which implementation of favoriteInt() does this call, Butler's implementation or Person's implementation? What value does this method call return? (b) (4 points) Suppose we call gotoh favoriteInt(). Which implementation of favoriteInt() does this call, Butler's implementation, or Person's implementation? What value does this method call return? (c) (4 points) What value does the following method call return: cm. favoriteInt()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
