Chapter 10 Quiz

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

____________ displays the variables and methods for all classes in a project. a)Class View b)Object Browser c)Design View d)None of the above

a)Class View

"This" is often used to distinguish between a local variable and class variable that share an identical name. a)True b)False.

a)True

A constructor may not have a return value. a)True b)False

a)True

A static variable represents class-wide information. a)True b)False

a)True

An object initializer calls the default constructor before executing. a)True b)False

a)True

An object initializer list cannot be empty. a)True b)False

a)True

An object of a class that has a reference to another object of the same class may access all the private data and methods of that class. a)True b)False

a)True

At least one argument of an operator overload method must be a reference to an object of the class in which the operator is overloaded. a)True b)False

a)True

Attempting to overload a constructor with another constructor that has the exact same signature (name and parameters) is a compilation error. a)True b)False

a)True

C# invokes the appropriate constructor by matching the number, types and order of the parameters in the constructor call to those in each constructor definition. a)True b)Fasle

a)True

Composition is a form of software reuse. a)True b)False

a)True

Developers use the Object Browser to learn about the functionality provided by a specific class. a)True b)False

a)True

Each object of a class has its ow copy of all the instance variables of the class. a)True b)False

a)True

Every class must have at least one constructor. a)True b)False

a)True

Methods that overload binary operators must take two arguments. a)True b)False

a)True

Objects can hide their implementation from other objects. a)True b)False

a)True

Operators should be overloaded to perform actions similar to those that they normally perform on objects of simple types. a)True b)False

a)True

The classes, variables and methods in a program are displayed in a hierarchical structure in Class View. a)True b)False

a)True

The data components of a class are called instance variables. a)True b)False

a)True

The public methods of a class present the services that a class provides. a)True b)False

a)True

The purpose of utility methods is to support the operation of a class' other methods. a)True b)False

a)True

User-defined classes may be composed of other user-defined classes. a)True b)False

a)True

Variables or methods declared with access modifier public are accessible wherever the program has a reference to an object of the class. a)True b)False

a)True

Variables that are static have class scope. a)True b)False

a)True

You cannot determine when the garbage collector will execute. a)True b)False

a)True

Which of the following describes a static variable? a)a variable with one copy shared by all class objects b)a variable whose value may not be changed c)all of the above d)none of the above

a)a variable with one copy shared by all class objecs

A class's ___________ initializes members of that class. a)constructor b)utility method c)access modifier d)none of the above

a)constructor

A ____________ can be defined in a class to perform termination housekeeping on an object before the garbage collector reclaims the object's memory. a)destructor b)property c)garbage collector d)none of the above

a)destructor

Which of the following statements is false? a)extension methods add functionality to a type by modifying the type's source code. b)LINQ capabilities are implemented as extension methods. c)Preceding an object parameter that's the first parameter in the method header with the "this" keyword indicates that the method extends an existing type. The compiler uses this information to add code into the compiled program that enables extension methods to work with existing types. d)The type of an extension method's first parameter specifies that type that you're extending.

a)extension methods add functionality to a type by modifying the type's source code.

Which of the following statements is true? a)methods and instance variables can be public, protected or private. b)information hiding is achieving by restricting access to class members via keyword public. c)the public members of a class are not directly accessible to the client of a class. d)none of the above is true

a)methods and instance variables can be public, protected or private.

Which statement is false? a)the compiler always creates a default constructor for a class. b)if a class has constructors, but none of the public constructors are parameterless, and a program attempts to call a parameterless constructor to initialize an object of the class, a compilation error occurs. c)a constructor can be called with no arguments only if the class does not have any constructors or if the class has a public parameterless constructor. d)parameterless constructors do not have any arguments.

a)the compiler always creates a default constructor for a class.

An object's this reference refers to: a)the object itself b)what the programmer assigned to this. c)the entry point of the program d)none of the above.

a)the object itself

A class cannot have references to objects of other classes as members. a)True b)False

b)False

A constructor may not call other methods. a)True b)False

b)False

A constructor should return either true or false to determine if the object was initialized properly. a)True b)False

b)False

A destructor has the same name as the class and its constructor. a)True b)False

b)False

A program contains a separate copy of a static variable for each object that's instantiated. a)True b)False

b)False

A static method may access static and non-static members. a)True b)False

b)False

An attempt by a method which is not a member of a particular class to access a private member of that class is a fatal runtime error. a)True b)False

b)False

Attempting to modify a readonly instance variable after it's initialized is a fatal execution-time error. a)True b)False

b)False

C# is like C++ in that programmers must manage memory explicitly. a)True b)False

b)False

Data members declared as readonly must be initialized in their declaration. a)True b)False

b)False

Member access modifiers are used to limit how much memory is available for class members. a)True b)False

b)False

Programmers should not take into consideration that their code will be modified. a)True b)False

b)False

The compiler will create a default constructor for a class even if you already declared a constructor(s). a)True b)False

b)False

The garbage collector looks for objects with no values. a)True b)False

b)False

Variables declared within class methods are called instance variables. a)True b)False

b)False

The use of references to objects of preexisting classes as members of new objects is called __________. a)inheritance b)composition c)polymorphism d)none of the above

b)composition

Object orientation uses classes to: a)develop algorithms b)encapsulate data and methods c)organize large amounts of data d)none of the above

b)encapsulate data and methods

You cannot validate values assigned to properties using an object initializer. a)true b)false

b)false

Composition is sometimes referred to as a(n) ___________. a)is-a relationship. b)has-a relationship c)have-a relationship d)one-to-many relationship

b)has-a relationship

Keyword __________ is used to indicate a method overloads a specific operator. a)implement b)operator c)overload d)op

b)operator

Keyword _________ is used for constants whose values cannot be determined at compile time. a)const b)readonly c)static d)none of the above

b)readonly

Failure to release resources when the program is no longer using them can cause _____________? a)buffer overflows b)resource leaks c)exceptions d)none of the above.

b)resource leaks

In a method in which a parameter has the same name as an instance variable, using the "this" reference allows you to refer to ______________. a)the parameter b)the instance variable c)varies depending on the situation d)none of the above

b)the instance variable

How many parameters does the default constructor that C# creates for you have? a)3 b)1 c)0 d)varies

c)0

Object initializers (which initialize an object and its properties) use what syntax? a)new className(property1 -> value1, ); b)new className(property1 = value1, ); c)new className{property1 = value1, }; d)className{property1 = value1, };

c)new className{property1 = value1, };

An instance of a user-defined type is called a(n). a)class b)interface c)object d)none of the above.

c)object

Instance variables or methods declared with the modifier are accessible only in that class definition. a)protected b)static c)private d)none of the above

c)private

A constructor cannot: a)be overloaded b)initialize variables to their defaults c)specify return types or return values. d)have the same name as the class.

c)specify return types or return values

Which of the following class members should usually be private? a)methods b)constructors c)variables d)all of the above

c)variables

Which of the following statements is false? a)A static method or property must be used to access private static instance variables. b)A static method has no "this" reference. c)A static method can be accessed even when no objects of its class have been instantiated. d)A static method can call instance methods directly.

d)A static method can call instance methods directly

Composition: a)Is a form of software reuse b)Is using an object reference as a class member c)Is a good design practice d)All of the above

d)All of the above

Having a this reference allows: a)A method to refer explicitly to the instance variables and other methods of the object on which the method was called. b)A method to refer implicitly to the instance variables and other methods of the object on which the method was called. c)An object to reference itself. d)All of the above.

d)All of the above

Every class inherits directly or indirectly from class _________. a)Inheritor b)Base c)Super d)Object

d)Object

Which of the following statements is true? Constructors: a)initialize instance variables b)when overloaded, can have identical argument lists c)when overloaded, are selected by number and types of parameters d)a and c

d)a and c

When should a program explicitly use the "this" reference? a)accessing a private variable b)accessing a public variable c)accessing a local variable d)accessing a field that is shadowed by a local variable

d)accessing a field that is shadowed by a local variable

The Object Browser _________________. a)lists all the classes in the C# library b)describes the functionality provided by a specific class c)is separated into 3 frames d)all of the above

d)all of the above

Which of the following statements is false? a)extension methods must be defined as static methods in a static class. b)the compiler implicitly passes the objects that's used to call the method as the extension method's first argument. This allows you to call an extension method as if it were an instance method of the extended class. c)an extension method's fully qualified name is the name of the class in which the extension method is defined, followed by the name of the method and its argument list. When using the fully qualified method name, you must specify an argument for the first parameter. d)if the type being extended defines an instance method with the same name as your extension method and a compatible signature, the extension method shadows the instance method.

d)if the type being extended defines an instance method with the same name as your extension method and a compatible signature, the extension method shadows the instance method.

[C#6] It's common to include in an exception's error message a variable's or property's identifier. This information can help a client-code programmer understand the context in which the exception occurred. Prior to C# 6, you had to hard code these identifiers into your error-message strings. As of C# 6, you can instead use the ________ operator, which returns a string representation of the identifier enclosed in parentheses. a)valueof b)string c)characters d)nameof

d)nameof


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

BIOS 2320-Microbiology and Infectious Diseases (MasteringMicro Ch. 3)

View Set

Chapter 8: Managing Human Resources

View Set

Chapter 4 - Agency Representation

View Set

Chapter 16: Investing in Preferred Stocks

View Set

DAT Entropy and Enthalpy, DAT Thermodynamics

View Set

Chapter 32: Closing the Transaction

View Set