Qz12

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Which statement best describes the relationship between base class and derived class types? - A derived class reference cannot be assigned to a base class variable and a base class reference cannot be assigned to a derived class variable. - A derived class reference can be assigned to a base class variable and a base class reference can be assigned to a derived class variable. - A base class reference can be assigned to a derived class variable, but a derived class reference cannot be assigned to a base class variable. - 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.

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: - Must implement a method called calculate. - Will not be able to access the instance variable a. - Will not be able to instantiate an object of class Foo. - All of the above.

All of the above

Select the best true statement - Polymorphism is indicated by a runtime warning from the FCL. - Polymorphism is indicated by the use of the keyword virtual in a method signature. - Polymorphism is indicated by the use of the keyword override in a method signature. - Both B and C are correct statements.

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 allow inlining the code. - sealed methods and classes prevent further inheritance. - sealed methods are static. - sealed methods can improve performance.

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 - a reference of the same type as the object - an object reference to the actual object - None of the above.

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

Polymorphism specifically enables the creation of programs that handle: - classes that are containers for other classes - large amounts of data with efficiency - a wide variety of classes in a general manner - None of the above

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 has an object of its base class. - because the derived class is an object of its base class. - only when the base class is abstract. - only when the base class is concrete

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

Polymorphism allows for specifics to be dealt with during: - execution - compilation - programming - debugging

execution

A(n) ____ is best used for providing services that bring together objects of otherwise unrelated classes. - abstract class - concrete class - interface - None of the above.

interface

Declaring a method sealed means: - it will prepare the object for garbage collection - it cannot be accessed from outside its class - it cannot be overloaded - it cannot be overridden

it cannot be overridden

The keyword sealed is applied to methods and classes to: - prevent overriding and inheritance - guarantee an implementation exists - specify a class is concrete - None of the above.

prevent overriding and inheritance

Polymorphism enables you to: - program in the general. - program in the specific. - absorb attributes and behavior from previous classes. - hide information from the user.

program in the general.

The purpose of an interface is to: - provide similar objects with the same functionality, even though each will implement the functionality differently - provide different types of objects with the comparable functionality, even though each will implement the functionality differently - provide default implementations of methods and properties - None of the above.

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 int method1(); - public int abstract method1(); - public abstract int method1(); - public int nonfinal method1();

public abstract int method1();


संबंधित स्टडी सेट्स

Oklahoma - Basic II Post License Course - Study Tests - Barnes Real Estate

View Set

ITN 261 CHAP 1-7 Pratice Question

View Set

Chinese Dynasty and Chinese Revolution

View Set

NU 273 PrepU Collecting Subjective Data: The Interview and Health History

View Set

Chapter 37: Assessment and Management of Patients With Allergic Disorders Prep-U

View Set

Indul a karaván - Első fejezet szavai

View Set

Step 4 - Apply Memorization Techniques

View Set