Introduction To Classes Test Questions & Answers Ch.10 - Test Bank | Visual C# 5e by Tony Gaddis. DOCX document preview.

Introduction To Classes Test Questions & Answers Ch.10

Starting Out with Visual C#, 5e (Tony Gaddis)

Chapter 10 Introduction to Classes

TRUE/FALSE

1. A class is not an object; it is a description of an object.

2. The class header defines a class's fields, properties, and methods.

3. The name of a class's constructor is the same as the name of the class.

4. A class's constructor header must specify a return type of void.

5. A class's constructor must always use the private access modifier.

6. When a class contains a method that uses the public access modifier, the method can be called from outside the class.

7. When you create an object from a class you use a reference variable to reference that object.

8. Because classes are reference types, objects that are instances of a class are always passed by reference.

9. In code that creates an instance of a class, you access the class object's properties in the same way that you would access public variables.

10. A property is a class member that behaves like a public field.

11. The set accessor is executed any time that a property is read.

12. The get accessor has an implicit parameter called a value.

13. Class fields are almost always declared private in order to protect them from accidental corruption.

14. If you try to pass a property to a ref or an out parameter, an error occurs.

15. To make a property read-only, omit the get accessor for the property.

16. To make a property read-only, omit the set accessor for the property.

17. An error will occur if you try to assign a value to a read-only property.

18. Constructors cannot accept arguments in the same way as other methods.

19. If two methods have the same names and parameter lists, you cannot overload them by just giving them different return types.

20. Constructors cannot be overloaded which means a class can only have one constructor.

21. Objects that are instances of a class cannot be stored in an array.

22. When you want to create a List object, you follow List with the name of a class inside angled brackets, and it specifies that the List can hold only objects of that class type.

23. When designing an object-oriented application, one of your first tasks is to identify the classes you need to create.

24. All of the nouns that appear in a problem description should become classes.

25. Once the classes have been identified in a problem description, the next task is to identify each class's responsibilities.

26. Every form in a Visual C# project is defined by a class.

27. When you have multiple forms in a project, you should give each form a meaningful name that describes its purpose.

28. Once you have added a form to a project, you can place any controls on it and write the necessary event handlers for the controls.

29. You can use the tabs appearing at the top of the Designer window to select different forms or their code to be displayed in the window.

30. Once a form has been created, it cannot be removed from a Visual Studio project.

31. In your application's code, the first step in displaying a form is to create an instance of the form's class.

32. Creating an instance of a form's class also displays the form on the screen.

33. Both instance fields and instance methods are associated with a specific instance of a class and cannot be used until an instance of the class is created.

34. When a value is stored in a static field or static property, it must be stored in an instance of the class.

35. When a field is declared with the static keyword, there is only one copy of the field in memory.

36. If a class is declared as static then all members of the class must be static or a compiler error will occur.

37. When a property is declared as static, the property's value in memory depends on the number of instances of the class that exist.

MULTIPLE CHOICE

1. Each object created from a class is called a(n) __________ of the class.

a.

object

b.

reference

c.

instance

d.

field

2. You create a class by writing a(n) __________.

a.

class declaration

c.

preprocessor directive

b.

object specification

d.

code blueprint

3. The first line of a class declaration is known as the __________.

a.

object heading

c.

data title

b.

class header

d.

class definition

4. A class's __________ are statements that define the class's fields, properties, and methods.

a.

overall body

c.

private elements

b.

field definitions

d.

member declarations

5. A(n) __________ is a method that is automatically executed when an object is created.

a.

actuator

b.

loader

c.

constructor

d.

executable

6. Classes are __________ types.

a.

reference

b.

value

c.

abstract

d.

binary

7. By using the __________ access modifier, a class can hide its data from code outside the class.

a.

public

b.

private

c.

const

d.

ref

8. Which of the following statements declares a variable named fox that references an instance of the Animal class?

a.

new Animal fox();

b.

Animal fox = new Animal();

c.

Animal fox;

d.

Animal new(fox);

9. Which of the following statements calls the Jump method of the Animal class using a reference variable named fox?

a.

Animal.fox.Jump();

b.

Animal(fox) = Jump();

c.

fox.Jump();

d.

fox = new Jump();

10. When you call a method and pass a class instance as an argument, the parameter variable becomes a(n) __________ to the object.

a.

copy

b.

reference

c.

address

d.

indicator

11. A __________ is a special type of class member that allows an object to store and retrieve a piece of data.

a.

variable

b.

field

c.

property

d.

method

12. A special set of methods, known as __________, work in conjunction with a private field.

a.

valuators

c.

getters and setters

b.

accessors

d.

transport methods

13. The __________ is a method that returns the property's value.

a.

Me method

c.

Show method

b.

get accessor

d.

this.Value method

14. In a property definition, the __________ is automatically created by the compiler and its data type is the same as that of the property.

a.

this variable

c.

copy variable

b.

data parameter

d.

value parameter

15. When a value is assigned to a property, the property's __________ is executed and the value being assigned is contained in the value parameter.

a.

set accessor

c.

return statement

b.

get accessor

d.

ToValue method

16. A __________ can be read but it cannot be modified.

a.

private field

c.

read-only property

b.

public field

d.

hidden property

17. When a field's value is dependent on other data and the field is not updated when its related data changes, we say the field has become __________.

a.

archaic

b.

stale

c.

obsolete

d.

frozen

18. A constructor that accepts arguments is known as a(n) __________.

a.

parameterized constructor

c.

constructor method

b.

alternate constructor

d.

aliased constructor

19. When a method is __________, it means that multiple methods in the same class have the same name but use different types of parameters.

a.

parameterized

b.

shadowed

c.

aliased

d.

overloaded

20. The process of matching a method call with the correct version of a method is known as __________.

a.

pairing

b.

signing

c.

binding

d.

matching

21. The compiler uses a method's __________ to distinguish it from other methods of the same name.

a.

binding

b.

return type

c.

name

d.

signature

22. A method's __________ is not part of the signature.

a.

return type

c.

parameter data type

b.

name

d.

argument kind

23. If you write a class with no constructor whatsoever, the compiler provides a(n) __________.

a.

error message

c.

nulll reference variable

b.

default constructor

d.

void constructor

24. When you create an array of a class type, each element of the array will be initialized with the value __________ by default.

a.

0

b.

null

c.

false

d.

void

25. To add an object of a class to a List you use the __________ method.

a.

Class

c.

Insert

b.

Add

d.

New

26. The __________ is the set of real-world objects, parties, and major events related to the problem.

a.

virtual world

c.

problem domain

b.

critical path

d.

project goal

27. Each of the __________ in the description of a problem domain is a potential class.

a.

verbs

c.

adjectives

b.

articles

d.

nouns

28. When you have identified the information that a class is responsible for knowing, then you have identified the class's __________.

a.

methods

c.

fields and/or properties

b.

names

d.

objects

29. When you have identified the actions that a class is responsible for doing, then you have identified the class's __________.

a.

methods

c.

fields and/or properties

b.

event handlers

d.

actions

30. When you add additional forms to a project, you add additional __________ which are stored in their own source code files.

a.

classes

b.

objects

c.

methods

d.

events

31. When working with multiple forms, use the __________ to change the name of the Form1.cs file to something more meaningful.

a.

Standard Toolbar

c.

Solution Explorer

b.

Toolbox

d.

Component Tray

32. To add a new form to a project, first click __________ on the Visual Studio menu bar and then select Add Windows Form... from the Project menu.

a.

Project

b.

File

c.

Tools

d.

Window

33. In Visual Studio you can easily switch your view to another form by double-clicking on the form's entry in the __________ window.

a.

Solution Explorer

c.

Designer

b.

Code

d.

Data Sources

34. If you wish to remove a form from a project and delete its file from the disk, first right-click on the form's entry in the Solution Explorer window and click __________ on the pop-up menu.

a.

Erase

b.

Remove

c.

Delete

d.

Purge

35. If you wish to remove a form from a project but you don't want to delete its file from the disk, first right-click on the form's entry in the Solution Explorer window and click __________ on the pop-up menu.

a.

Hide Form Only

c.

Archive Form Data

b.

Remove From Project

d.

Exclude From Project

36. Suppose a project has a form named SummaryForm. Which of the following statements creates an instance of the SummaryForm class and assigns it to a variable?

a.

SummaryForm.ShowDialog();

b.

SummaryForm = this.Form();

c.

mySummaryForm = SummaryForm();

d.

mySummaryForm = new SummaryForm();

37. The __________ method displays a form on the screen and it gives that form the focus.

a.

this.Focus

c.

Activate

b.

ShowDialog

d.

NewForm

38. When a __________ form is displayed, no other form in the application can receive the focus until the form is closed.

a.

static

b.

modal

c.

modeless

d.

primary

39. If you want to show a form in modeless fashion, call its __________ method.

a.

this.Modeless

c.

ShowDialog

b.

Show

d.

PopUp

40. Static methods operate on __________.

a.

the fields or properties of all instances of the class

b.

only on static fields and static properties

c.

only on static fields

d.

only on properties of the constructor

41. Which of the following is the correct way to create a static method named PoundsToKg that converts pounds to kilograms?

a.

public static double PoundsToKg(double p)

{

return p / 2.2;

}

b.

static double PoundsToKg(double p)

{

return p / 2.2;

}

c.

public(static) double PoundsToKg(double p = p / 2.2);

d.

public double PoundsToKg.static(double p)

{

return p / 2.2;

}

42. Which of the following is the correct way to declare a static field named myCount?

a.

private int static myCount = 1;

b.

private static int myCount = 1;

c.

private int myCount.static = 1;

d.

private static myCount(int) = 1;

43. To access a static property, you use __________.

a.

the class

c.

an instance of the class

b.

the constructor

d.

You cannot access a static property.

44. Which of the following statements about static methods is true?

a.

A static method cannot refer to nonstatic methods of the class.

b.

If a static method uses any of the class's fields, those fields must also be static.

c.

If a static method uses any of the class's properties, those properties must also be static.

d.

All of the above are true.

Document Information

Document Type:
DOCX
Chapter Number:
10
Created Date:
Aug 21, 2025
Chapter Name:
Chapter 10 Introduction To Classes
Author:
Tony Gaddis

Connected Book

Test Bank | Visual C# 5e

By Tony Gaddis

Test Bank General
View Product →

$24.99

100% satisfaction guarantee

Buy Full Test Bank

Benefits

Immediately available after payment
Answers are available after payment
ZIP file includes all related files
Files are in Word format (DOCX)
Check the description to see the contents of each ZIP file
We do not share your information with any third party