Question: Exercises Given the following classes: public class BakeryItem { / * fields and methods omitted for brevity * / } public class FoodItem { /
Exercises
Given the following classes:
public class BakeryItem
fields and methods omitted for brevity
public class FoodItem
fields and methods omitted for brevity
public class FrenchBreadItem
fields and methods omitted for brevity
public class Wheel
fields and methods omitted for brevity
public class Tomato
fields and methods omitted for brevity
public class FruitItem
fields and methods omitted for brevity
public class CarItem
fields and methods omitted for brevity
a Arrange the above classes into an appropriate inheritance hierarchy. Note: do
NOT add fields or methods to any of these classes.
b Add default constructor for each class, which prints "I am a YYYY For
example, the Tomato class should print "I am a tomato". In addition, the parent
information should be printed too.
c Implement a test class that instantiates a new instance for each class.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
