Question: Suppose you are tasked with writing classes and/or interfaces in Java for the following: The data type Magical is for things that say a magical

Suppose you are tasked with writing classes and/or interfaces in Java for the following:
The data type Magical is for things that say a magical phrase. Its only method is
magicPhrase(), which returns the magical phrase as a String. Magical does not supply
an implementation of this method. Instead, this method is to be implemented by sub-
types of Magical.
Data type Princess is both a sub-type of class Person (from question 1) and a sub-type
of Magical.
A Princess has a hair length (stored in a data field of type int called hairLength).
The class user can view the hairLength of a Princess (using a get method), but they
cannot modify the hairLength.
The constructor of Princess is accessible by the class user. Its parameters are the
name, age, and hair length (in this order). Call these parameters name, age and hairLen
respectively. It takes these parameters and initializes its corresponding data fields to these values
queston: Method favoriteInt() is overridden in Princess to do the following: call Persons
implementation of favoriteInt(), add hairLength to this, and return this resulting
sum.
Method magicPhrase() is overridden in Princess to return
favoriteInt() + " sparkles for everyone!"
(a) Should Magical be an abstract class, a non-abstract class, or an interface?
Explain your reasoning.
(b) What members (data fields and methods) does Princess inherit from class
Person?
(c) (4 points) Should the constructor for Princess have an explicit call to the constructor
c) Should the constructor for Princess have an explicit call to the constructor
of class Person? If so, write the line of code for this call. If not, explain why not.
(d) Write Java code for the data type Princess as described above.
all of these especially the last one

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!