Explore a diverse range of topics and get expert answers on IDNLearn.com. Find the information you need quickly and easily with our reliable and thorough Q&A platform.
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
Thank you for using this platform to share and learn. Keep asking and answering. We appreciate every contribution you make. IDNLearn.com has the solutions to your questions. Thanks for stopping by, and come back for more insightful information.