Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following simplified UML class diagram ( we omit visibility of variables and return types of methods ) : Animal super class, Cat and

Consider the following simplified UML class diagram (we omit visibility of variables and return types of methods):
Animal super class, Cat and Dog child classes of Animal, Cat and Dog implements Vocalisable
Consider the method private void addCats():
/**
* Creates instances of Animal, Cat and Dog
* and an ArrayList.
*/
private void addCats(){
Animal myAnimal = new Animal();
Cat myCat = new Cat("Kitty", "Persian cat");
Dog myDog = new Dog("Woofer", "Golden Retriever");
ArrayList cats = new ArrayList();
//code selected below will go here
}
Based on the given simplified UML class diagram and code snippet above, select all code statements that can be added to addCats() without compile-time or runtime errors:
Question 12Select one or more:
cats.add(myDog);
cats.add((Cat) myAnimal);
cats.add((Cat) myDog);
cats.add(myAnimal);
cats.add(myCat);

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

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions

Question

1. Organize and support your main points

Answered: 1 week ago

Question

3. Move smoothly from point to point

Answered: 1 week ago

Question

5. Develop a strong introduction, a crucial part of all speeches

Answered: 1 week ago