Java Chapter 11

¡Supera tus tareas y exámenes ahora con Quizwiz!

Only abstract classes can be used to declare class arrays

False

Which of the following statements is true? a. Superclass objects are members of their subclass. b. Superclasses can contain abstract methods. c. You can create an abstract class object using the new operator. d. An abstract class cannot contain an abstract method.

Superclasses can contain abstract methods.

An application's ability to select the correct subclass method to execute is known as _________ method binding.

dynamic

An abstract method has a body

false

Inheritance enables you to write programs that you could not write otherwise

false

You create an interface when you want to provide data or methods that subclasses can inherit, but at the same time, these subclasses maintain the ability to override the inherited methods

false

When you create a class that uses an interface, you include the keyword _________ and the interface's name in the class header.

implements

In Java, a class can _________.

inherit from one abstract superclass at most

The alternative to multiple inheritance in Java is known as a(n) _________.

interface

When you create a superclass and one or more subclasses, each object of the subclass _________ superclass object.

is a

The Object class is defined in the _____________ package

java.lang

Interface

looks much like a class, except that all of its methods must be abstract and all of its data (if any) must be static final; it declares method headers, but not the instructions with in those methods

The Object class equals() method considers two object references to be equal if they have the same _________.

memory address

The capability to inherit from more than one class is called _________

multiple inheritance

You can instantiate concrete objects from a(n) _________. a. abstract class b. interface c. either a or b d. neither a nor b

neither a nor b

A______ is a name collection of classes

package

Static or fixed method binding

the opposite of dynamic method binding; it occurs when a subclass method is selected when the program compiles rather than while it is running

Default package

the unnamed package in which a class is placed if you do not specify a package for the class

The Object class_______ method converts an Object into a String that contains information about the Object

toString()

A class can extend another without implementing any interfaces

true

You can indirectly create a reference to a superclass abstract object

true

Ad-hoc polymorphism

when polymorphic behavior depends on method overloading

You _________ override the toString() method in any class you create.

can

Abstract classes differ from other classes in that you _________.

cannot instantiate objects from them

Java ARchive (JAR) file

compresses the stored data

toString() method

converts an Object into a String that contains information about the Object.

Which statement creates an array of five references to an abstract class named Currency? a. Currency[] = new Currency[5]; b. Currency[] currencyref = new Currency[5]; c. Currency[5] currencyref = new Currency[5]; d. Currency[5] = new Currency[5];

b. Currency[] currencyref = new Currency[5];

Abstract classes can contain _________.

both Abstract and nonabstract methods

When you want to provide some data or methods that subclasses can inherit, but you want the subclasses to override some specific methods, you should write a(n) _________.

abstract class

Late method binding

another term for dynamic method binding

An abstract class Employee has two subclasses, Permanent and Temporary. The Employee class contains an abstract method named setType(). Before you can instantiate Permanent and Temporary objects, which of the following statements must be true? a. You must code statements for the setType() method within the Permanent class. b. You must code statements for the setType() method within both the Permanent and Temporary classes. c. You must not code statements for the setType() method within either the Permanent or Temporary class. d. You can code statements for the setType() method within the Permanent class or the Temporary class, but not both.

You must code statements for the setType() method within both the Permanent and Temporary classes.

Multiple inheritance

the capability to inherit from more than one class

Virtual classes

the name given to abstract classes in other programming languages such as C++

Parent classes are _________ than their child classes.

Less Specific

Hash code

a calculated number used to identify an object

An abstract class Product has two subclasses, Perishable and NonPerishable. None of the constructors for these classes requires any arguments. Which of the following statements is legal? a. Product myProduct = new Product(); b. Perishable myProduct = new Product(); c. NonPerishable myProduct = new NonPerishable(); d. none of the above

NonPerishable myProduct = new NonPerishable();

Collisions

a term that describes class naming conflicts

A____class is one from which you cannot create any concrete objects, but from which you can inherit

abstract

Assume the following statement appears in a working Java program: if(thing.equals(anotherThing)) x = 1; You know that _________.

anotherThing is the same type as thing

The Object class equals() method returns a(n) ________value indicating whether the objects are equal

boolean

equals() method

takes a single argument, which must be the same type as the type of the invoking object, and returns a boolean value indicating whether two object references are equal

Dynamic method binding

the ability of an application to select the correct subclass method when the program executes

Abstract methods

declared with the keyword abstract. This type of method has no body-no curly braces and no method statements-just a return type, a method name, and optional argument list, and a semicolon. You are required to code a subclass method to override the empty superclass method that is inherited

Object class

defined in the java.lang package, which is imported automatically every time you write a program;it includes methods that you can use or override. When you define a class, if you do not explicitly extend another class, your class is an extension of the Object class.

Concrete classes

nonabstract classes from which objects can be instantiated

Java subclasses have the ability to inherit from _________ parent class(es).

one

The Object class equals() method takes _________.

one argument

Abstract class

one from which you cannot create any concrete objects, but from which you can inherit. Abstract classes usually have one or more empty abstract methods

Inclusion polymorphism

polymorphic behavior depends on using the superclass as a method parameter

Pure polymorphism

polymorphic behavior depends on using the superclass as a method parameter

When you create a _________ in Java, you create a variable name in which you can hold the memory address of an object.

reference


Conjuntos de estudio relacionados

Carbohydrates Dynamic Study Module

View Set

Tissue: Epithelial Connective, Nervous, and Muscle

View Set

Module 12 Mobile Device Forensics and the Internet of Anything

View Set