Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Principles Programming And Performance

Authors: Patrick O'Neil

1st Edition

1558603921, 978-1558603929

More Books

Students also viewed these Databases questions

Question

13-1 How does building new systems produce organizational change?

Answered: 1 week ago

Question

13-4 What are alternative methods for building information systems?

Answered: 1 week ago