Carrano Chapter 9

Ace your homework & exams now with Quizwiz!

When is a method in a subclass said to override a method in the superclass?

A method in a subclass is said to override a method in the superclass if the two methods have the same declarations.

How can a package be created in Java?

A package can be created by placing a package statement at the top of each class file that is part of the package.

What is a subinterface?

A subinterface is an interface that is derived from an existing interface.

What is an abstract class?

An abstract class is a class without instances that forms the basis of other classes that descend from it.

What is an access modifier?

An access modifier is a keyword which is used to control the visibility of the members of a class.

What kind of relationship exists between a superclass and a subclass?

An is-a relationship exists between a superclass and a subclass.

What is containment?

Containment is a relationship between classes whereby one class contains an instance of another class.

What is meant by dynamic binding?

Dynamic binding is a situation in which the appropriate version of a method is decided at execution time.

______ enables the reuse of existing classes. Encapsulation Inheritance Polymorphism Simulation

Inheritance

______ is the ability of a class to derive properties from a previously defined class. Encapsulation Simulation Inheritance Polymorphism

Inheritance

What is meant by object type compatibility?

It is a characteristic of objects that enables you to use an instance of a subclass where an instance of the superclass is expected, but not the converse.

Name two things that an abstract class may include that an interface would not.

Method implementations, and data members.

What is method overloading?

Method overloading is when a method is created that has the same name as another method, but a different set of parameters.

______ is the ability of a variable name to represent, during program execution, instances of different but related classes that descend from a common superclass. Inheritance Containment Polymorphism Encapsulation

Polymorphism

What are some of the advantages of using an object-oriented approach to the development of a software?

Previously implemented classes can be reused in future programs. Program maintenance is easier. Program verification is easier.

What is meant by static binding?

Static binding is a situation in which the appropriate version of a method is determined at compilation time.

What does the reference super represent?

The reference super represents the object reference for the superclass.

What are the two basic kinds of relationships among classes?

The two kinds of relationships are: is-a relationship and has-a relationship.

What kind of methods are appropriate to implement in an abstract class?

Those that provide access to private data fields, or that express functionality common to all of its subclasses.

What is an advantage to defining an ADT that uses a generic data type? .

When retrieving an item from the ADT, it won't be necessary to cast the return value from Object, and we can thus avoid class cast exceptions if the type of the data in the collection was inappropriate

Is it legal for a subclass of an abstract class not to implement all of the methods it inherits? Briefly explain.

Yes, but it would then have to declare those unimplemented methods as abstract.

Can the object type of an argument in the call to a method be difference from the object type of the corresponding formal parameter? Explain.

Yes, the two object types can be different. The object type of an argument in a call to a method can be a subclass of the corresponding formal parameter's object type.

A subclass that fails to implement all of the abstract methods of its superclass must be declared as a(n) ______ class. abstract static final private

abstract

If a method definition in a superclass has the field modifier ______, a subclass is required to override the method. static protected final abstract

abstract

Which of the following is NOT true about packages? a package can contain other packages a package's name must be the same as the directory that contains all of the classes in the package a Java source file that is part of a named package must contain a statement at the top of the file that contains the keyword package and the name of the package all classes in a package are available to clients of the package

all classes in a package are available to clients of the package

The class from which another class is derived is known as the ______. base class subclass child class final class

base class

Java packages provide a way to group related ______ together. objects data structures variables classes

classes

A subclass inherits all of the following members of its superclass EXCEPT ______. public methods data fields constructors protected methods

constructors

The class which inherits the members of another class is known as the ______. superclass derived class base class abstract class

derived class

A subclass is said to be a ______ of its superclass. descendant relative leaf mirror

descendant

Static binding is also known as ______. early binding late binding package binding inheritance binding

early binding

The keyword ______ is used in the class declaration of a subclass to indicate its superclass. inherits extends implements super

extends

A base class is a class that inherits the members of another class.

false

A package cannot contain other packages

false

A subclass cannot add new members to those it inherits from the superclass.

false

A superclass's private data fields can be revised by one of its subclasses.

false

An instance of a superclass can be used anywhere an instance of its subclass is expected.

false

Clients of a class can directly access the protected members of that class.

false

If the field modifier ______ is specified in a method definition, the method cannot be overridden by a subclass. public protected final abstract

final

Methods declared as ______ use static binding. protected final public abstract

final

Containment is another name for a(n) ______ relationship. is-a has-a has-many similar-to

has-a

A Java ______ specifies behaviors that are common to a group of classes. package final class interface subclass

interface

nheritance should only be used when a(n) ______ relationship exists between the superclass and the subclass. is-a has-a has-many similar-to

is-a

Which of the following is true about an abstract class? it can be instantiated it can contain zero or more abstract methods it cannot be inherited by other classes it cannot contain data fields

it can contain zero or more abstract methods

A(n) ______ is a class that is used to provide access to another class that contains many objects. interface abstract class package iterator

iterator

Dynamic binding is also known as ______. early binding late binding package binding inheritance binding

late binding

Name 3 important operations that an iterator object can perform.

next( ) hasNext( ) remove( )

A method that has the same name but a different set of parameters as an existing method is said to ______ the original method. bind cancel override overload

overload

A method in a subclass is said to ______ an inherited method if it has the same method declarations as the inherited method. copy override overload cancel

override

A class's ______ members can only be used by its own methods. public protected private package access

private

In general, a class's data fields should be declared as ______. public protected private package access

private

The ______ access modifier hides the members of a class from the class's clients but makes them available to a subclass and to another class within the same package. public protected private package access

protected

A class's ______ members are available to instances of all classes. public protected private package access

public

In a class within a package, the keyword ______ must appear in front of the class keyword to make the class available to clients of the package. open public protected package

public

A superclass method can be accessed by a subclass, even though it has been overridden by the subclass, by using the ______ reference. super final static new

super

The constructor of a subclass can call the constructor of the superclass by using the ______ reference. extends new super import

super

A package and the directory that contains all the classes in the package must have the same name.

true

A subclass can contain its own version of an inherited method.

true

An instance of a subclass can access the protected members of the superclass.

true

Inheritance should not be used to implement a has-a relationship.

true


Related study sets

Chapter 19: Workforce Engagement and Collective Action

View Set

BUS 101 - Module 4: Operating Systems and File Management

View Set

Level I Antiterrorism Awareness Training

View Set