Question: 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
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
