C# Quiz 12

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan 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: (code)

All of the above.

Select the best true statement:

Both B and C are correct statements.

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

False

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

False

When used correctly, polymorphism will never require changes to be made to any part of the program.

False

You may define implementations for abstract methods to act as default implementations.

False

An abstract base class can be used to declare references.

True

An abstract class may be derived from another abstract class.

True

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

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

True

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

True

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

True

The abstract methods and properties of a class do not provide an implementation.

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 method1 in abstract class Class1 (method1 returns an int and takes no arguments)?

public abstract int method1();

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

sealed methods are static.


Set pelajaran terkait

Chapter 6 Implementation and evaluation

View Set

And Then There Were None Chapters 1-7

View Set

Chapter 5: Operating Systems, 2223 MIS Intro to computers exam 2, Chapter 9, Introduction to Computers Final Exam, CIS Ch.7, MIS Chapter 1, MIS Test 4- know acronyms, Computers Module 12, module 11 quizzes, Module 9 and 10

View Set

Business Math Ch 14: Cost of Installment Buying

View Set

Chapter 7: Suitability and Investment Risks UNIT EXAM

View Set