Qz12

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

Which statement best describes the relationship between base class and derived class types?

A derived class reference can be assigned to a base class variable, but a base class reference cannot be assigned to a derived class variable.

Consider the abstract class below: public abstract class Foo { private int a; public int b; public Foo( int aVal, int bVal ) { a = aVal; b = bVal; } // end Foo constructor public abstract int calculate(); } // end class Foo Any concrete subclass that extends class Foo:

All of the above

Select the best true statement

Both B and C are correct statements.

T/F Attempting to instantiate an object of an abstract class is a logic error.

False

T/F Polymorphism allows the addition of classes providing they were at least considered during program development.

False

T/F When used correctly, Polymorphism will never require changes to be made to any part of the program.

False

T/F You may define implementations for abstract methods to act as default implementations

False

Classes and methods are declared sealed for all of the following reasons, except:

Sealed methods are static

T/F An abstract class may be derived from another abstract class.

True

T/F If a derived class reference is assigned to a base class variable, the variable must be cast back to the derived class before any derived class methods can be called with it.

True

T/F Polymorphism allows you to command a wide variety of objects even if you do not know the objects' types.

True

T/F Polymorphism enables objects of different classes that are related by a class hierarchy to be processed generically

True

T/F Sealing methods allows the compiler to optimize the program by "inlining code."

True

T/F The abstract methods and properties of a class do not provide an implementation

True

T/F an abstract base class can be used to declare references

True

If a method needs to be called polymorphically, what type of reference should be used to point to the object that the method is being called with?

a reference of the base class that defines the behavior of the object

Polymorphism specifically enables the creation of programs that handle:

a wide variety of classes in a general manner

Assigning a derived class reference to a base class variable is safe:

because the derived class is an object of its base class.

Polymorphism allows for specifics to be dealt with during:

execution

A(n) ____ is best used for providing services that bring together objects of otherwise unrelated classes.

interface

Declaring a method sealed means:

it cannot be overridden

The keyword sealed is applied to methods and classes to:

prevent overriding and inheritance

Polymorphism enables you to:

program in the general.

The purpose of an interface is to:

provide different types of objects with the comparable functionality, even though each will implement the functionality differently

Which declaration declares abstract method method 1 in abstract class Class1 (method 1 returns an int and takes no arguments)?

public abstract int method1();


Kaugnay na mga set ng pag-aaral

L' alphabet - The alphabet (Mots)

View Set

Nursing 2371 Exam 1 (Ch. 3 & 11)

View Set

Academic Team Full Practice Set 8

View Set

chapter 12: antimicrobial treatment

View Set