CH 10: Introduction to Inheritance

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

When you use the method name with a child object, the parent's version of the method is used.

False

____ is a mechanism that enables one class to acquire all the behaviors and attributes of another class.

Inheritance

A nonstatic method cannot override a static member of a parent class.

True

It is useful to override the parent class members when the superclass data fields and methods are not completely appropriate for the subclass objects.

True

Subclasses are more specific than the superclass they extend.

True

When a protected data field or method is created, it can be used within its own class or in any classes extended from that class; but it cannot be used by outside classes.

True

Programmers and analysts sometimes use a graphical language to describe classes and object-oriented processes. This language is called ____.

UML

Arrows used in a ____ to show inheritance relationships extend from the descendant class and point to the original class.

UML diagram

When you create a class and do not provide a(n) ____, Java automatically supplies you with a default one.

constructor

Usually, the subclass constructor only needs to initialize the ____ that are specific to the subclass.

data fields

You use the keyword ____ to achieve inheritance in Java.

extends

An advantage to making a method ____ is that the compiler knows there will be only one version of the method.

final

You can use the ____ modifier with methods when you don't want the method to be overridden.

final

When you employ ____, your data can be altered only by the methods you choose and only in ways that you can control.

information hiding

If a programming language does not support ____, the language is not considered object-oriented.

polymorphism

Using the keyword ____ provides you with an intermediate level of security between public and private access.

protected

If a ____ method has the same name as a parent class method and you use the name with a child class object, the child method hides the original.

static

Which of the following statements depicts the valid format to call a superclass constructor from a subclass constructor?

super(name, score);

In Java, all instance method calls are ____ by default.

virtual method calls

If jrStudent is an object of Student, which of the following statements will result in a value of true?

jrStudent instanceof Student

Which statement correctly declares a sedan object of the Car class?

Car sedan = new Car();

In a UML diagram, an inheritance relationship is indicated with an arrow that points from the original class to the descendant class.

False

When you create any subclass object, the subclass constructor must execute first, and then the superclass constructor executes.

False

You cannot declare a class to be final.

False

____ polymorphism is the ability of one method to work appropriately for subclasses of the same parent class.

Subtype

A class diagram consists of a rectangle divided into three sections.

True

An error is generated by the compiler when you attempt to override a static method with a nonstatic method.

True

The class used as a basis for inheritance is the ____ class.

base

The term ____ describes a "has a" relationship.

containment

By convention, a class diagram contains the ____ following each attribute or method.

data type

You are never aware that ____ is taking place; the compiler chooses to use this procedure to save the overhead of calling a method.

inlining

The ability to use inheritance in Java makes programs easier to write, ____, and more quickly understood.

less error-prone

When you create a class by making it inherit from another class, the new class automatically contains the data fields and _____ of the original class.

methods

Sometimes the superclass data fields and methods are not entirely appropriate for the subclass objects; in these cases, you want to ____ the parent class members.

override

The term ____ means "many forms."

polymorphism

The methods in a subclass can use all of the data fields and methods that belong to its parent, with one exception: ____ members of the parent class are not accessible within a child class's methods.

private

In most Java classes, the keyword ____ precedes each data field, and the keyword ____ precedes each method.

private, public

Which of the following statements will create a class named Red that is based on the class Color?

public class Red extends Color

You can use the keyword ____ within a method in a derived class to access an overridden method in a base class.

super

When you create parent and child classes of your own, the child classes use ____ constructors.

three


Kaugnay na mga set ng pag-aaral

Blood Therapy practice questions

View Set

Equilibrium in the short and long run

View Set

Process of Science: Observation Techniques, Mastering Astronomy, Astronomy 2, Chapter 6, Astro ch6, ASTR 102 Chapter 6: Telescopes: Portals of Discovery, Astronomy 101 Study Guide

View Set

Chapter 26: Transition Metals and Coordination Compounds

View Set

Phys Exam 5: Regulation of Metabolism

View Set

PhiDE Family Tree Prestige Priority

View Set