Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Based on the Bear class you were given and the BrownBear class just described, select the correct answers below: ( a ) Select the true

Based on the Bear class you were given and the BrownBear class just described, select the correct answers below:
(a) Select the true statements about the Bear class
If the Bear class implemented the following interface:
public interface Captive
{
void encloseWith(Bear otherBear);
}
then Bear would have to provide a concrete method with signature encloseWith(Bear).
The equals method in Bear must be overridden in any subclasses to allow instances of subclasses to be passed as arguments.
It is possible to declare a variable of type Bear.
The toString method in Bear could not have called the foodFrequency method in BrownBear even though this uses the method getFoods declared in Bear.
Methods such as setHabitat need to be declared as abstract in order for the Bear class to compile.
As hashCode has not been implemented in Bear, the hashCode method inherited from Object cannot be implemented in any of its subclasses.
The equals method in Bear will consider instances of any subclass equal if they have the same species.
(b) Select the true statements about the BrownBear class
If the Bear class had included an abstract method:
public void encloseWith(Bear otherBear);
Then this could have been implemented in BrownBear by a method with the header:
public void encloseWith(BrownBear otherBear)
The foods list in Bear could be sorted in BrownBear using the syntax getFoods().sort()
It would be possible to clear the list of foods in Bear by means of a method in BrownBear with the code:
public void clearFoods()
{
getFoods()= new ArrayList();
}
If the method toString in class BrownBear does not have an @Override annotation then toString from Bear will be executed for objects of class BrownBear.
The class BrownBear must declare a constructor in order to be compiled.
Question 8Not yet answered

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

Genomes And Databases On The Internet A Practical Guide To Functions And Applications

Authors: Paul Rangel

1st Edition

189848631X, 978-1898486312

More Books

Students also viewed these Databases questions