Chapter 10: Object-Oriented Programming: Polymorphism Q7

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

All of the following methods are IMPLICITYLY FINAL except:

A METHOD in an abstract class.

Which statement best describes the RELATIONSHIP between superclass and subclass types?

A SUBCLASS reference CAN be ASSIGNED to a superclass variable, but a superclass reference cannot be assigned to a subclass variable.

Which of the following is not possible?

A class that inherits from two classes.

For which of the following would polymorphism NOT PROVIDE a CLEAN solution?

A program to compute a 5% SAVING account interest for a variety of clients. Because there is only one kind of calculation, there is no need for polymorphism.

Which of the following statements about INTERFACES is FALSE?

AN INTERFACE describes a set of methods that can be called on an object, providing a default implementation for the methods.

Interfaces can have methods.

ANY NUMBER of

Assigning a subclass reference to a superclass variable is SAFE:

BECAUSE the subclass object IS AN object of its superclass.

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).

Both (a) and (b).

Non-abstract classes are called:

CONCRETE classes

Polymorphism allows for specifics to be DEALT WITH during:

EXECUTION

The UML DISTINGUISHES an interface from other classes by placing the word "interface" in above the interface name.

GUIllemets.

If the superclass contains only ABSTRACT method declarations, the superclass is used for:

INTERFACE inheritance.

It is a UML CONVENTION to denote the name of an abstract class in:

ITALics

Which keyword is used to specify that a class will define the methods of an interface?

Implements.

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. early binding. b. non-binding. c. on-time binding. d. late binding.

LATE binding (also called dynamic binding).

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.

NONE

An INTERFACE MAY contain:

PUBLIC STATIC FINAL data and public abstract methods.

A class that implements an interface but DOES NOT DECLARE all of the interface's methods must be declared:

abstract

A(n) class cannot be instantiated.

abstract

Which of the following statements about abstract superclasses is true?

abstract superclasses MAY CONTAIN data

Which of the following does not complete the sentence correctly? An interface

can be INSTANTIETED

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.

final methods are STATIC

Every object in Java knows its own class and can access this information through method . a. getClass. b. getInformation. c. objectClass. d. objectInformation.

getClass.

Declaring a method final means:

it CANNOT be OVERRIDDEN

Polymorphism ENABLES you to:

program in the GENERAL

Which of the following could be used to declare abstract method method1 in ABSTRACT class CLASS1 (method1 returns an int and takes no arguments)?

public ABSTRACT int method1();


Ensembles d'études connexes

Chapter 34: The Child with Musculoskeletal or Articular Dysfunction

View Set

ITALIAN CULTURE THROUGH MUSIC MIDTERM

View Set

EMT Pocket Prep: SIGW w/explanations

View Set

FI 305 Morosan - Chapters 9 & 10

View Set

Chapter 3 Energy, Chemical Reactions, and Cellular Respiration

View Set