Question
(Please answer this in 10 minits) class IceCream extends Food{ private String flavour; public String getFlavour(){ return this .flavour; } public boolean equals(IceCream iceCream){ return
(Please answer this in 10 minits)
class IceCream extends Food{
private String flavour;
public String getFlavour(){
return this.flavour;
}
public boolean equals(IceCream iceCream){
return this.flavour == iceCream.flavour;
}
}
(a)What are the errors in the following code for 'IceCream' class? [Hint: The errors are all in the 'equals' method and there are 3]
(b)Rewrite the 'equals' method in the 'IceCream" class correcting all the existing errors.
(c)Override the 'howToPrepare()' method in the 'IceCream' class to return the String "Ice cream: Freeze it!".
(d) How would you define an abstract method named 'howToPrepare()' in 'Food' class that returns a String? [Just write the relevant java code line(s) only]
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started