JAVA 3252 Chapter 11 polymorphism

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Which of the following statements about interfaces is false? A. An interface describes a set of methods that can be called on an object, providing a default implementation for the methods. B. An interface describes a set of methods that can be called on an object, not providing concrete implementation for the methods. C. Interfaces are useful when attempting to assign common functionality to possibly unrelated classes. D. Once a class implements an interface, all objects of that class have an is-a relationship with the interface type

A. An interface describes a set of methods that can be called on an object, providing a default implementation for the methods.

Which of the following statements about abstract superclasses is true? A. abstract superclasses may contain data. B. abstract superclasses may not contain implementations of methods. C. abstract superclasses must declare all methods as abstract. D. abstract superclasses must declare all data members not given values as abstract.

A. abstract superclasses may contain data.

Polymorphism allows for specifics to be dealt with during: A. execution. B. compilation. C. programming. D. debugging.

A. execution.

Every object in Java knows its own class and can access this information through method . A. getClass. B. getInformation. C. objectClass. D. objectInformation.

A. getClass.

Polymorphism enables you to: A. program in the general. B. program in the specific. C. absorb attributes and behavior from previous classes. D. hide information from the user.

A. program in the general.

Which of the following is not possible? A. A class that implements two interfaces. B. A class that inherits from two classes. C. A class that inherits from one class, and implements an interface. D. All of the above are possible.

B. A class that inherits from two classes.

Assigning a subclass reference to a superclass variable is safe: A. because the subclass object has an object of its superclass. B. because the subclass object is an object of its superclass. C. only when the superclass is abstract. D. only when the superclass is concrete.

B. because the subclass object is an object of its superclass.

Which keyword is used to specify that a class will define the methods of an interface? A. uses. B. implements. C. defines. D. extends.

B. implements.

If the superclass contains only abstract method declarations, the superclass is used for: A. implementation inheritance. B. interface inheritance. C. Both. D. Neither.

B. interface inheritance.

It is a UML convention to denote the name of an abstract class in: A. bold. B. italics. C. a diamond. D. there is no convention of the UML to denote abstract classes—they are listed just as any other class.

B. italics

Constants declared in an interface are implicitly A. private. B. static. C. abstract. D. All of the above.

B. static.

For which of the following would polymorphism not provide a clean solution? A. A billing program where there is a variety of client types that are billed with different fee structures. B. A maintenance log program where data for a variety of types of machines is collected and maintenance schedules are produced for each machine based on the data collected. C. A program to compute a 5% savings account interest for a variety of clients. D. An IRS program that maintains information on a variety of taxpayers and determines who to audit based on criteria for classes of taxpayers.

C. A program to compute a 5% savings account interest for a variety of clients

A class that implements an interface but does not declare all of the interface's methods must be declared: A. public. B. interface. C. abstract. D. final.

C. abstract.

Classes and methods are declared final for all but the following reasons: A. final methods allow inlining the code. B. final methods and classes prevent further inheritance. C. final methods are static. D. final methods can improve performance.

C. final methods are static.

The UML distinguishes an interface from other classes by placing the word "interface" in above the interface name. A. italics. B. carets. C. guillemets. D. bold

C. guillemets.

Which of the following could be used to declare abstract method method1 in abstract class Class1 (method1 returns an int and takes no arguments)? A. public int method1(); B. public int abstract method1(); C. public abstract int method1(); D. public int nonfinal method1();

C. public abstract int method1();

An interface may contain: A. private static data and public abstract methods. B. only public abstract methods. C. public static final data and public abstract methods. D. private static data and public final methods.

C. public static final data and public abstract methods.

Which statement best describes the relationship between superclass and subclass types? A. A subclass reference cannot be assigned to a superclass variable and a superclass reference cannot be assigned to a subclass variable. B. A subclass reference can be assigned to a superclass variable and a superclass reference can be assigned to a subclass variable. C. A superclass reference can be assigned to a subclass variable, but a subclass reference cannot be assigned to a superclass variable. D. A subclass reference can be assigned to a superclass variable, but a superclass reference cannot be assigned to a subclass variable.

D. A subclass reference can be assigned to a superclass variable, but a superclass reference cannot be assigned to a subclass variable.

Consider the abstract superclass below: public abstract class Foo{ private int a; public int b; public Foo( int aVal, int bVal ) { a = aVal; b = bVal; } // end Foo constructor public abstract int calculate(); } // end class Foo Any concrete subclass that extends class Foo: A. Must implement a method called calculate. B. Will not be able to access the instance variable a. C. Neither (a) nor (b). D. Both (a) and (b)

D. Both (a) and (b)

Consider classes A, B and C, where A is an abstract superclass, B is a concrete class that inherits from A and C is a concrete class that inherits from B. Class A declares abstract method originalMethod, implemented in class B. Which of the following statements is true of class C? A. Method originalMethod cannot be overridden in class C—once it has been implemented in concrete class B, it is implicitly final. B. Method originalMethod must be overridden in class C, or a syntax error will occur. C. If method originalMethod is not overridden in class C but is called by an object of class C, an error occurs. D. None of the above.

D. None of the above.

Interfaces can have methods. A. 0 B. 1 C. 2 D. any number of

D. any number of

Which of the following does not complete the sentence correctly?An interface . A. forces classes that implement it to declare all the interface methods. B. can be used in place of an abstract class when there is no default implementation to inherit. C. is declared in a file by itself and is saved in a file with the D. can be instantiated.

D. can be instantiated.

Declaring a method final means: A. it will prepare the object for garbage collection. B. it cannot be accessed from outside its class. C. it cannot be overloaded. D. it cannot be overridden.

D. it cannot be overridden.

When a superclass variable refers to a subclass object and a method is called on that object, the proper implementation is determined at execution time. What is the process of determining the correct method to call? A. execution time binding. B. execution binding. C. just-in-time binding. D. late binding

D. late binding.

All of the following methods are implicitly final except: A. a method in an abstract class. B. a private method. C. a method declared in a final class. D. static method.

a method in an abstract class.

A(n)_________class cannot be instantiated. A. final. B. concrete. C. abstract. D. polymorphic.

abstract

Non-abstract classes are called:

concrete


Ensembles d'études connexes

anatomy and physiology: chapter 12

View Set

CHAPTER 2 Strategic Leadership: Managing the Strategy Process

View Set

ADV5503 Media Consumer Behavior Exam 2 Study Guide

View Set

Chapter 20 (Campylobacter and Helicobacter) and Chapter 21 (Nonfermenters and Misfits)

View Set

Quantitative reasoning 4 DAT REVIEW

View Set