C# FINALLL

Ace your homework & exams now with Quizwiz!

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

0

Which of the following statements is false? a. A derived class is generally larger than its base class. b. A base class object is a derived class object. c. The class following the ":"in a class declaration is the direct base class of the class being declared. d. C# does not support multiple inheritance.

A base class object is a derived class object.

Which statement is false? The actual data representation used within the class is of no concern to the class's clients. b) Clients generally care about what the class does but not how the class does it. c) Clients are usually involved in a class's implementation. d) Hiding the implementation reduces the possibility that other program parts will become dependent on class-implementation details

Clients are usually involved in a class's implementation.

The concept of data abstraction refers to the fact that a client does not know how a class's functionality is implemented, just how to use it.

TRUE

The data components of a class are called instance variables.

TRUE

The process of abstraction allows you to focus on the commonalities among objects in the system.

TRUE

The public methods of a class present the services that a class provides.

TRUE

The purpose of utility methods is to support the operation of a class' other methods.

TRUE

User-defined classes may be composed of other user-defined classes.

TRUE

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

TRUE

Variables that are static have class scope.

TRUE

You cannot determine when the garbage collector will execute.

TRUE

this is often used to distinguish between a local variable and class variable that share an identical name.

TRUE

1. 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.

The compiler always creates a default constructor for a class.

Inheritance is represented by a(n) ________ relationship. a) "uses" b) "is-a" c) "has-a" d) None of the above.

b) "is-a"

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

The term information hiding refers to: a) public methods b) hiding implementation details from clients of a class c) accessing static class members d) the process of releasing an object for garbage collection

b) hiding implementation details from clients of a class

Which of the following pairs demonstrates the has-a relationship between the first and the second terms? a) car, vehicle b) house, window c) teacher, person d) None of the above

b) house, window

A data structure can be described as a "waiting line." a) stack b) queue c) list d) None of the above.

b) queue

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

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

An advantage of inheritance is that: a) all methods can be inherited b) all instance variables can be uniformly accessed by base classes and derived classes c) Objects of a derived class can be treated like objects of their base class d) None of the above.

c) Objects of a derived class can be treated like objects of their base class

Which of the following is not a base/derived class relationship? a) Ford/Taurus b) University/Boston University c) Sailboat/Tugboat d) Country/USA

c) Sailboat/Tugboat

Which of the following pairs demonstrates the is-a relationship between the first and the second terms? a) car, engine b) book, table of contents c) baseball, sport d) None of the above

c) baseball, sport

Instance variables declared readonly do not or cannot: a) use the principle of least privilege b) be initialized c) be modified once the object is constructed d) cause syntax errors if used as a left-hand value

c) be modified once the object is constructed

Stacks are commonly referred to as data structures. a) first-in, last-out b) first-in, first-out c) last-in, first-out d) None of the above.

c) last-in, first-out

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

The _________ of a class are also called the public services or the public interface of the class. a) public constructors b) public instance variables c) public methods d) All of the above

c) public methods/members

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.

1. Which of the following should usually be private? a) methods b) constructors c) variables d) All of the above

c) variables

Which of the following 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.

Abstract Data Types: a) elevate the importance of data b) are approximations or models of real-world concepts and behaviors c) capture two notions—data representation and operations d) All of the above

d) All of the above

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.

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.

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

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

d) object

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.

a has- a relationship is implemented via inheritancce

false

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, ... };

new className { property1 = value1, ... };

the ____ states that code should be granted only the amount of access needed to accomplish its task

principle of least priviledge

Objects can hide their implementation from other objects.

TRUE

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

TRUE

Every class must have at east one constructor.

TRUE

10. A constructor should return either true or false to determine if the object was initialized properly.

FALSE

A base class may have only one derived class.

FALSE

A class cannot have references to objects of other classes as members.

FALSE

A constructor may not call other methods.

FALSE

A derived class is often larger and more general than its base class.

FALSE

A destructor has the same name as the class and its constructor

FALSE

A program contains a separate copy of a static variable for each object that's instantiated

FALSE

A static method may access static and non-static members.

FALSE

An attempt by a method which is not a member of a particular class to access a pri-vate member of that class is a fatal runtime error

FALSE

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

FALSE

C# is extensible because altering the base language is as simple as it's easy to extend via new types.

FALSE

C# is like C++ in that programmers must manage memory explicitly.

FALSE

Clients are normally allowed to manipulate the data representation of a queue structure directly.

FALSE

Data members declared as readonly must be initialized in their declaration.

FALSE

Every object of a base class is an object of that class's derived classes.

FALSE

Inheritance is the process of building a class with object references of other classes.

FALSE

Instances of a class are called class variables.

FALSE

Items are returned from a queue in last-in, first-out (LIFO) order. The last item inserted in the queue is the first item removed from the queue.

FALSE

Member access modifiers are used to limit how much memory is available for class members.

FALSE

Members of a base class that are private are not inherited by derived classes.

FALSE

Multiple inheritance, widely used in C#, is the process of inheriting from more than one class.

FALSE

Only certain objects have a this reference.

FALSE

Only the first constructor for a class is defined without a return value. Subsequent constructors have the return type void.

FALSE

Programmers should not take into consideration that their code will be modified.

FALSE

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

FALSE

The garbage collector looks for objects with no values.

FALSE

Variables declared within class methods are called instance variables.

FALSE

You cannot validate values assigned to properties using an object initializer.

FALSE

A class that inherits from another class is referred to as the derived class.

TRUE

A client of a stack class need not know how the stack is implemented. The client simply requires that when data items are placed in the stack, they will be recalled in last-in, first- out order. This concept is referred to as data abstraction, and C# classes define abstract data types (ADTs).

TRUE

A constructor may not have a return value.

TRUE

A derived class can effect state changes in base class private members only through public, protected, internal methods provided in the base class and inher-ited into the derived class

TRUE

A static variable represents class-wide information.

TRUE

All classes in C# have object as either a direct or indirect base class.

TRUE

An object initializer calls the default constructor before executing.

TRUE

An object initializer list cannot be empty.

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.

TRUE

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

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.

TRUE

Composition is a form of software reuse.

TRUE

Constructors are not inherited.

TRUE

Developers use the Object Browser to learn about the functionality provided by a specific class.

TRUE

Each object of a class has its own copy of all the instance variables of the class.

TRUE

________ 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

2. Which of the following statements is true? a)Methods and instance variables can be public, protected or private. b) Information hiding is achieved 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 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 objects

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

A class inherited from two or more levels up in the hierarchy is known as a . a) indirect base class b) direct base class c) superclass d) None of the above

a) indirect base class

Identify which of the following examples could be considered a base class for the Computer class? a) machine b) hard-drive c) software d) keyboard

a) machine

A derived class cannot access the members of its base class. a) private b) static c) protected d) None of the above.

a) private

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

a) the object itself


Related study sets

Professional nursing concepts and practice final

View Set

PrepU Chapter 27: Safety, Security, and Emergency Preparedness

View Set

Measurement, reliability and validity

View Set

Ch 13: Labor and Birth Processes

View Set

Tech Enabled Business Transformation

View Set

Precalculus Chapter 2: Polynomial and Rational Functions - LIONS

View Set