Question
What are the errors in the following code for 'IceCream' class? [Hint: The errors are all in the 'equals' method and there are 3] class
What are the errors in the following code for 'IceCream' class? [Hint: The errors are all in the 'equals' method and there are 3]
class IceCream extends Food{
private String flavour;
public String getFlavour(){
return this.flavour;
}
public boolean equals(IceCream iceCream){
return this.flavour == iceCream.flavour;
}
}
1. 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]
2. Override the 'howToPrepare()' method in the 'IceCream' class to return the String "Ice cream: Freeze it!".
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