Scientific Prog Ch10

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

references (F.I.B.)

Although we cannot instantiate objects of abstract superclasses, we can declare _____ of abstract superclass types.

polymorphism

Uses superclass references to manipulate sets of subclass objects in a generic manner.

is-a (F.I.B.)

When a class implements an interface, it establishes an _____ relationship with the interface type.

subclass (F.I.B.)

When a method is invoked through a superclass reference to a subclass object, Java executes the version of the method found in the _____.

layered software systems

Polymorphism is particularly effective for implementing _____.

Describe the concept of polymorphism.

Polymorphism makes it possible to design and implement systems that are more easily extensible. Programs can be written to process objects generically as one type, and new classes can be added with little or no modifications to the generic part of the program. For example, a program can be designed to draw shapes rather than to draw rectangles, ovals and lines. Each shape object would know how to draw itself.

getClass method

Returns an object that can be used to determine information about the object's class.

abstract, abstract, abstract

You make a class _____ by declaring it with keyword abstract. An _____ class normally contains one or more _____ methods.

constructors and static methods

_____ and _____ cannot be declared abstract.

abstract methods

_____ do not provide implementations.

concrete class

A class that can be used to create objects.

abstract, abstract, concrete, concrete, abstract, concrete, abstract

A class that contains any _____ methods must be declared as an _____ class even if it contains some _____ methods. Each _____ subclass of an _____ superclass must provide _____ implementations of each of the superclass's _____ methods.

What happens when a class specifies that it implements an interface, but does not provide declarations of all the methods in the interface?

A compilation error occurs in this case. Every method in the interface must be implemented, or the class must be declared abstract to prevent this compilation error.

interface (F.I.B.)

A(n) _____ may contain a set of public abstract methods and/or public static final fields.

cannot

Abstract classes _____ be used to instantiate objects, because they're incomplete.

sometimes constitute

Abstract classes _____ several levels of a hierarachy.

instanceof

Anoperator that returns true if its left operand( a variable of a reference type ) has the is-a relationship with its right operand ( a class or interface name ).

Describe how to determine the class name of an object's class.

Call method getClass on an object to obtain an object of type Class that represents the object's type. Then call the Class object's getName method to get a String containing the class's name.

interface

Can be used in place of an abstract class when there is no default implementation to inherit.

abstract class

Cannot be instantiated; used primarily for inheritance.

downcasting

Casting a superclass reference to a subclass reference.

getName method

Class method which returns the name of the class associated with the Class object.

implements keyword

Indicates that a class will declare each method in an interface with the signature specified in the interface declaration.

final

Indicates that a method cannot be overridden or that a class cannot be a superclass.

abstract (F.I.B.)

It is a syntax error if a class with one or more abstract methods is not explicitly declared _____.

downcasting (F.I.B.)

It is possible to assign a superclass reference to a subclass variable by _____ the reference to the subclass type.

abstract method

Must be overridden in a subclass; otherwise, the subclass must be declared abstract.

polymorphism (F.I.B.)

With ______, it becomes possible to design and implement systems that are more extensible.

Distinguish between an abstract class and a concrete class.

An abstract class can be used as a superclass and to declare variables that can store references to objects of the abstract class's subclass. An abstract class cannot be used to create objects. A concret class can be used to create objects and declare variables. In addition, a concrete class can also be used as a superclass as long as it is not declared final.

type-wrapper classes

Classes in the java.lang package that are used to create objects containing values of primitive types.

instantiate, concrete classes

Classes that can be used to _____ objects are called _____. Such classes provide implementations of every method they declare (some of the implementations can be inherited).

Define what it means to declare a method final and what it means to declare a class final.

Declaring a method final means that the method cannot be overridden in a subclass. Declaring a class final means that it cannot be a superclass (i.e., a class cannot inherit from a final class). Methods in a final class are implicitly final.

abstract classes, abstract superclass types

Not all inheritance hierarchies contain _____. However, programmers often write client code that uses only _____ to reduce client code's dependencies on a range of specific subclass types.

instanceof (F.I.B.)

The _____ operator determines whether the type of the object to which its left operand refers has an is-a relationship with the type specified as its right operand.

superclass, inherit

The primary purpose of an abstract class is to provide an appropriate _____ from which other classes can inherit and thus share a common design.

implements (F.I.B.)

To use an interface, a class must specify that it _____ the interface and must declare every method in the interface with the signatures specified in the interface declaration.

class type, type

When the compiler encounters a method call made through a variable, the compiler determines if the method can be called by checking the variable's _____. If that class contains the proper method declaration (or inherits one), the call is compiled. At execution time, the _____ of the object to which the variable refers determines the actual method to use.

abstract, variables, abstract, variables

You can use _____ superclasses to declare _____ that can hold references to objects of any concrete class derived from those _____ superclasses. Programs typically use such variables to manipulate subclass objects polymorphically.


Set pelajaran terkait

Write Formulas for Ionic Compounds

View Set

confidence intervals and t-distribution

View Set