Answered step by step
Verified Expert Solution
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 encloseWithBear otherBear;
then Bear would have to provide a concrete method with signature encloseWithBear
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 encloseWithBear otherBear;
Then this could have been implemented in BrownBear by a method with the header:
public void encloseWithBrownBear otherBear
The foods list in Bear could be sorted in BrownBear using the syntax getFoodssort
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 Not yet answered
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