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

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!