Westonci.ca connects you with experts who provide insightful answers to your questions. Join us today and start learning! Get immediate and reliable answers to your questions from a community of experienced experts on our platform. Experience the ease of finding precise answers to your questions from a knowledgeable community of experts.
Sagot :
Answer:
a) public class Bear extends Animal{ ... }
public class Zoo { private Animal[] myAnimals;
... }
Explanation:
The question is an illustration of inheritance in Java programming language.
The syntax to follow is:
class subclass extends superclass {...}
From the question:
Bear [tex]\to[/tex] subclass
Animal [tex]\to[/tex] superclass
So, the following declaration will be used:
class Bear extends Animal{ ... }
Also from the question, the zoo object represents collection of many animals.
So, its declaration will follow:
class class-name{ ..... }
i.e.
class zoo{ .... }
The ... can then be replaced with declaration of each animal or an array to represent the declarations..
Hence, (e) is correct
The most appropriate set of declarations is; Option E
What is the best programming pattern?
From the parameters given in the question, we can say that;
Bear is a subclass
Animal is a superclass
This means that the declaration that will be used is;
public class Bear extends Animal{ ... }
Now, we also see that Zoo are declared to represent animal, bear and zoo objects. Thus, the declaration would be;
public class Zoo
{
private Animal[] myAnimals;
...
}
Looking at the given options, only option E is correct.
Read more about Java Programming at; https://brainly.com/question/18554491
We hope our answers were helpful. Return anytime for more information and answers to any other questions you may have. We appreciate your visit. Our platform is always here to offer accurate and reliable answers. Return anytime. We're here to help at Westonci.ca. Keep visiting for the best answers to your questions.