Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

The act polymorphic methods for the character classes of Beauty and the Beast started

with a call to
to super.act(); Which of the following describes correctly the use of that method call?

D
A. The call is required to properly instantiates the constructor of the superclass.
B. The call is required to properly initiate polymorphism in the umbrella superclass.
C. The call is required for any subclass methods that re-define the act method.
D. The call is not required, but is beneficial to handle execution common to all actors.
E. The call is not required, but is beneficial to understand the program flow of
polymorphism

Animal m = new Mammal();


Animal b = new Bird();
Animal f = new Fish();

A. They are all three superclasses B


B. They are all three subclasses or implementing classes
C. They are all three umbrella classes.
D. At least one class is a superclass.
E. No assumption can be made about the classes.

ArrayList<RailCar> railCars = new


ArrayList<RailCar>();
If this statement can be used for RailCar
polymorphism, what is the umbrella
identifier

ArrayList<RailCar> railCars = new


ArrayList<RailCar>();
No, but you can tell what the umbrella
Is it possible to tell if there is an
identifier is.
umbrella interface or an umbrella class
used by this statement?

// Assume that the Language is the superclass for classes English, German, Dutch and French.

public static void main(String[] args)


{
ArrayList<Language> countries = new ArrayList<Language>();//1

countries.add(new Language());//2
countries.add(new English()); //3
countries.add(new German()); //4
countries.add(new Dutch()); //5
1-6
countries.add(new French()); //6

for (Language country : countries){ //7


country.greeting(); //8
}

Which program statements of the main method set up polymorphism


// Assume that the Language is the superclass for classes English, German, Dutch and French.

public static void main(String[] args)


{
ArrayList<Language> countries = new ArrayList<Language>();//1

countries.add(new Language());//2
countries.add(new English()); //3
countries.add(new German()); //4
countries.add(new Dutch()); //5
7/8
countries.add(new French()); //6

for (Language country : countries){ //7


country.greeting(); //8
}

Which program statements of the main method use polymorphism

class Language{(greeting method)}

class German{(greeting method)}


There isn't any you doofus
class Dutch{(greeting method)}

What is the class interaction

Consider the program examples in


Chapter 14 used for Beauty and the
Beast actors. A superclass
Which of the following is the best choice
for an umbrella?

Consider the program examples in


Chapter 14 used for the Lab 14a
assignment displaying shapes. An interface
Which of the following is the best choice
for an umbrella?

Consider the program examples in


Chapter 14 used for the train cases study.
A superclass
Which of the following is the best choice
for an umbrella?
The drawCar polymorphic methods for the train case study started with a
call to to super.drawCar(); Which of the following describes correctly the
use of that method call?

A. The call is required to properly instantiates the constructor of the


superclass.
B. The call is required to properly initiate polymorphism in the umbrella
superclass. D
C. The call is required for any subclass methods that re-define the act
method.
D. The call is not required, but is beneficial to handle execution common to
all actors.
E. The call is not required, but is beneficial to understand the program flow
of polymorphism

for (RailCar railCar : railCars)


railCar.drawCar(g);

The railCars array contains objects of different classes. The drawCar method of each
method is called.
Since there are different objects in the array, there are also different implementations of the
drawCar method available. How is the correct drawCar method called.

A. Each drawCar method that is different gets a different memory location when the
C
program is finished
B. At compile-time every version of the polymorphic method is connection to a memory
location.
C. At run-time every version of the polymorphic method is connected to a memory
location
D. With early binding when the bytecode file is created

for (RailCar railCar : railCars)


railCar.drawCar(g);
drawCar
What is the polymorphic method in this
program code?

How is the "cookies" analogy an example of using


polymorphsim?

A. Large companies store information about customer


preferences on company computers
B. Customers are asked to uptain theri preference for a company C
profile
C. Companies make customer computers responsible for
customer preferences
D. Cookies do not use polymorphism, but protect customers
from unwanted company searches.

inferface Language{(greet)}

class German extends Language{(greet)}

class Dutch extends Language{(greet)}

What is the class interaction

A. The language interface is the umbrella for German and Dutch classes
E
B. The German and Dutch classes are con tained with composition in the Language class

C. The Language class is contained inside the German and Dutch classes with composition.

D. The Language class is the superclass for the German and Dutch implementing classes

E. Both A and D
inferface Language{(greet)}

class German implements Language{(greet)}

class Dutch implements Language{(greet)}

What is the class interaction

A. The language interface is the umbrella for German and Dutch classes
A
B. The German and Dutch classes are con tained with composition in the Language class

C. The Language class is contained inside the German and Dutch classes with composition.

D. The Language class is the interface for the German and Dutch implementing classes

E. Both A and D

(Lab14a main method)

This program demonstrates something about polymorphism that was not


shown by the Language program, the Train program and the Beauty and the
Beast program. What is it?

A. The use of ArrayList to call the polymorphic method efficiently.


B. The fact that there can be more than one polymorphic method in one
B
interface or class.
C. The use of graphics to demonstrate polymorphism
D. Using a for..each loop structure to traverse an array.
E. Nothing is shown in this program code that was not already shown by the
three programs mentioned

Out of all the five railCar classes, whats


railCar
the umbrella

An overloaded method is connected to


early-binding
a memory location by a process called

(Picture of a bunch of railcars)

The appearance of the images helps


explain why one of the following super.drawCar
methods is used in the re-definition of
every polymorphic method of the train
program
(Picture of a bunch of railcars)
drawCar
What is the polymorphic method of the
train program?

A polymorphic method is connected to


late-binding
a memory location by a process called

public static void main(String[] args)


{
Language lan1 = new English();
Language lan2 = new German();
Language lan3 = new Dutch();
Language lan4 = new French();
printGreeting(lan1);
printGreeting(lan2);
printGreeting(lan3);
printGreeting(lan4);

D
}
public static void printGreeting(Language obj)
{
obj.greeting();
}

Given only the provided program code with the two methods on this page, which of the following is false?

A. English, German, Dutch, and French implement Language.


B. English, German, Dutch, and French extend Language.
C. Language is an umbrella interface or an umbrella class
D. printGreeting is the polymorphic method defined in the English, German, Dutch, and French
E. There is evidence of inheritance, but no evidence of polymorphism

public static void main(String[] args)


{
Language lan1 = new English();
Language lan2 = new German();
Language lan3 = new Dutch();
Language lan4 = new French();
printGreeting(lan1);
printGreeting(lan2);
printGreeting(lan3);
printGreeting(lan4);

C
}
public static void printGreeting(Language obj)
{
obj.greeting();
}

Given only the provided program code with the two methods on this page, which of the following is true?

A. English, German, Dutch, and French implement Language.


B. English, German, Dutch, and French extend Language.
C. Language is an umbrella interface or an umbrella class
D. printGreeting is the polymorphic method defined in the English, German, Dutch, and French
E. There is evidence of inheritance, but no evidence of polymorphism

The railCar array contains objects of different


classes. The drawCar method of each method is
called. At run-time every version of the
polymorphic method is connected to a
Since there are different objects in the array,
there are also different implementations of the memory location
drawCar method available. How is the correct
drawCar method called
(Shape class)
All the shape(number)(shape)
Which classes need to re-define
polymorphic methods

When is a polymorphic method


During run-time
connected to a memory location?

When will the next test be? uR mUm

You might also like