Unit 11 Reviewing the Basics Quiz

Ace your homework & exams now with Quizwiz!

Two of the following statements are true, and one is false. Identify the false statement:

a. If Parent is a parent class and Child is its child, then you can assign a Child object to a Parent reference. ***b. If Parent is a parent class and Child is its child, then you can assign a Parent object to a Child reference. *** c. Dynamic method binding refers to a program's ability to select the correct subclass method for a superclass reference while a program is running.

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

True

Two of the following statements are true, and one is false. Identify the false statement:

a. Abstract classes usually have one or more empty abstract methods. b. An abstract method has no body, curly braces, or statements. ***c. An abstract class is one from which you cannot inherit, but from which you can create concrete objects.***

Two of the following statements are true, and one is false. Identify the false statement:

a. All of the methods in an interface are implicitly public and abstract, and all of its data items (if any) are implicitly public, static, and final. b. When a class inherits from another, the child class can use the nonprivate, nonoverridden members of its parent's class, but when a class uses an interface, it must implement its own version of each method. **c. Java's capability to inherit from more than one class is called multiple inheritance.***

Two of the following statements are true, and one is false. Identify the false statement:

a. An anonymous inner class is defined inside another class. b. If an anonymous inner class extends another class, the superclass must have a default constructor. **c. You use the keyword extends when defining the class an anonymous inner class.***

Which statement creates an array of five references to an abstract class named Currency ?

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

Abstract classes differ from other classes in that you ____________.

b. cannot instantiate objects from them

Assume the following statement appears in a working Java program and that the equals() method has been overridden correctly in thing's class: if(thing.equals(anotherThing)) x = 1; You know that ____________.?

c. anotherThing is the same type as thing

Abstract classes can contain ____________.

c. both abstract methods and nonabstract methods

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

c. reference

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

can

You can instantiate concrete objects from a(n) ____________.

d. neither abstract classes nor interfaces

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

dynamic

Two of the following statements are true, and one is false. Identify the false statement:

**a. A class that will be placed in a package for others to use must be protected so that others cannot read your source code.** b. Typically, you place .class files in a package so other programmers can import them into their programs. c. Java's creators have defined a package-naming convention in which you use your Internet domain name in reverse order

Parent classes are more specific than their child classes.

False

Two of the following statements are true, and one is false. Identify the false statement:

a. If object-oriented programs did not support inheritance, programs still could be written, but they would be harder to write. ***b. When you create a new subclass in Java, you must remember to revise and recompile the superclass code. *** c. When you create a useful, extendable superclass, you save development and testing time.

Two of the following statements are true, and one is false. Identify the false statement:

a. The Object class is defined in the java.lang package that is imported automatically every time you write a program. b. When you define a class, if you do not explicitly extend another class, your class is an extension of the Object class. **c. The Object class toString() and equals() methods are abstract**

Two of the following statements are true, and one is false. Identify the false statement:

a. You can assign subclass objects to an array that is their superclass type. ***b. You can assign a superclass reference to an array of its subclass type.*** c. The following statement creates an array of 10 Table references: Table[] table = new Table[10]

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 both the Permanent and Temporary classes.

The Object class equals() method takes two arguments.

b. False

An abstract class Dwelling has two subclasses, SingleFamily and MultiFamily. None of the constructors for these classes requires any arguments. Which of the following statements is legal?

d. SingleFamily myHome = new SingleFamily();

Which of the following statements is true?

d. Superclasses can contain abstract 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) ____________.

d. abstract class

In Java, a class can ____________.

d. inherit from one abstract superclass at most

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

d. memory address

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

implements

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

interface

Each Java subclass has the ability to inherit from ____________ parent class(es).

one


Related study sets

Most common STDs (Sexually Transmitted Diseases)

View Set

Chapter 7: Metamorphism and Metamorphic Rocks

View Set

General Education Review - SEMINAR 1 MATHEMATICS

View Set

Crafting and Executing Strategy: Chapter 12

View Set