Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Step: 3

blur-text-image

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

Informix Database Administrators Survival Guide

Authors: Joe Lumbley

1st Edition

0131243144, 978-0131243149

More Books

Students also viewed these Databases questions