Modularizing Your Code With Methods Chapter 6 Test Bank - Test Bank | Visual C# 5e by Tony Gaddis. DOCX document preview.

Modularizing Your Code With Methods Chapter 6 Test Bank

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

Chapter 6 Modularizing Your Code with Methods

TRUE/FALSE

1. In a general sense, a class is a collection of statements that performs a specific task.

2. If a specific task is performed in several places in a program, a method can be written once to perform that task and then be executed any time it is needed.

3. Every method must have a nonempty parameter list.

4. A method definition has two parts: a header and a body.

5. When the keyword void appears in the method header, it means the method will return a value.

6. When a method is declared with the private access modifier, it can be called only by code inside the same class as the method.

7. In a method header, the name is always followed by a set of parentheses.

8. The method header is always terminated with a semicolon.

9. When a method is called the program branches to that method and executes the statements in the method body.

10. A mathematical expression, such as A * B, cannot be passed as an argument to a method containing a value parameter.

11. A mathematical expression, such as A * B, cannot be passed as an argument to a method containing a reference parameter.

12. You can pass string literals as arguments to methods containing string parameters.

13. You can pass int arguments into int parameters but you cannot pass double or decimal arguments into int parameters.

14. When calling a method and passing a variable as an argument, always write the data type and the variable name of the argument variable in the method call.

15. A parameter variable can be accessed by any statement outside the method in which the parameter variable is declared.

16. You have to write the data type for each parameter variable in a parameter list.

17. Default arguments must be literals or constants.

18. If you provide a default argument for the first parameter in a list, you do not need to provide default arguments for the remaining parameters.

19. Passing an argument by reference guarantees that the argument will not be changed by the method it is passed into.

20. If you call a method that has a reference parameter, you must also write the keyword ref before the argument.

21. When you pass an argument to a ref parameter, that argument must already be set to some value.

22. When you call a method that has an output parameter, you must also write the keyword out before the argument.

23. The debugger's Step Over command lets you view all statements inside a method being called by the current program statement.

24. Suppose you set a breakpoint inside a method named X. When you reach a statement that calls method X the Step Over command will stop at the breakpoint.

25. Suppose you're using the debugger to step through a method and you want to immediately return to the place in the program where the method was called. The Step Return command will accomplish this.

26. The debugger's Step Into command lets you view all statements inside a method being called by the current program statement.

27. A method that has an output parameter must set the output parameter to some value before it finishes executing.

28. When you call a method that has an output parameter, you do not need to assign an initial value to the argument variable.

29. void methods are useful for simplifying complex conditions that are tested in decision and repetition structures.

30. You can write methods that return any data type.

MULTIPLE CHOICE

1. Dividing a large problem into several smaller programs that are each easily solved is sometimes called __________.

a.

programmatic simplification

c.

top-down design

b.

divide and conquer

d.

parallel design

2. In general terms, a program that is broken into smaller units of code, such as methods, is known as a __________.

a.

tiered project solution

c.

modularized program

b.

method-based solution

d.

divisional program

3. The benefit from dividing code into methods known as __________ is gained as follows: After you write code to perform a task once, you can use the code again every time your program needs to perform that same task.

a.

code recycling

c.

logic recycling

b.

software engineering

d.

code reuse

4. When you call a __________ method, it executes its code and returns without passing any value back to the program statement that called it.

a.

void

c.

value-returning

b.

terminal

d.

private

5. When you call a __________ method, it executes the statements it contains and then returns a value back to the program statement that called it.

a.

void

c.

value-returning

b.

recursive

d.

public

6. The __________ which appears at the beginning of a method definition lists several important things about the method. These include the method's name and a list of parameters.

a.

method description

c.

method specification

b.

method body

d.

method header

7. The __________ is a collection of statements that are performed when a method is executed.

a.

executable code

c.

method code listing

b.

method body

d.

method header

8. It is a standard convention among C# programmers to use __________ for method names because it differentiates method names from variable and field names.

a.

camelCase

c.

Pascal case

b.

lowercase characters

d.

uppercase characters

9. Which of the following statements correctly calls a method named ShowName?

a.

private void ShowName()

c.

Call.ShowName();

b.

ShowName();

d.

ShowName;

10. The memory address that is saved by the system when a method is called and is the location to which the system should return after a method ends is known as the __________.

a.

method address

c.

return point

b.

virtual break

d.

jump position

11. Data values passed to a method when it is called are known as __________.

a.

references

b.

variables

c.

arguments

d.

parameters

12. A(n) __________ is a variable that receives an argument which is passed into a method.

a.

parameter

b.

argument

c.

reference

d.

constant

13. When you pass an argument to a method, the argument's data type must be __________ with the receiving parameter's data type.

a.

assignment compatible

c.

data bound

b.

user friendly

d.

identical to

14. A parameter variable's scope is the __________ in which the parameter variable is declared.

a.

namespace

b.

class

c.

field

d.

method

15. When a method contains multiple parameters, they are often referred to collectively as a(n) __________.

a.

reference list

c.

parameter list

b.

parameter set

d.

argument list

16. A method containing a(n) __________ allows you to specify which parameter variable the argument should be passed to.

a.

named argument

c.

named constant

b.

dynamic parameter

d.

alternative argument

17. When a __________ is provided for a parameter, it is possible to call the method without explicitly passing an argument into the parameter.

a.

named argument

c.

default argument

b.

Boolean value

d.

bitwise operator

18. When an argument is __________, only a copy of the argument's value is passed into the parameter variable.

a.

passed by reference

c.

named

b.

passed by value

d.

uninitialized

19. When you want a method to be able to change the value of a variable that is passed to it as an argument, the variable must be __________.

a.

passed by reference

c.

a value parameter

b.

passed by value

d.

a variable parameter

20. __________ are useful for returning more than one value from a method.

a.

Reference parameters

c.

Default arguments

b.

Named arguments

d.

Parameter lists

21. A(n) __________ works like a reference parameter, but the argument does not have to be set to a value before it is passed into the parameter.

a.

parameter list

c.

output parameter

b.

named argument

d.

named constant

22. In C# you declare a reference parameter by writing the __________ keyword before the parameter variable's data type.

a.

const

b.

ref

c.

out

d.

private

23. In C# you declare an output parameter by writing the __________ keyword before the parameter variable's data type.

a.

const

b.

ref

c.

out

d.

public

24. When a __________ method finishes, it returns a value to the statement that called it.

a.

public

c.

void

b.

value-returning

d.

private

25. A value-returning statement must have a(n) __________ statement.

a.

return

c.

logical

b.

assignment

d.

void

26. In a value-returning method the type of data the method returns is commonly called the method's __________.

a.

method value

c.

assigned value

b.

named type

d.

return type

27. You can use a(n) __________ to test a conditional expression and return either true or false.

a.

reference parameter

c.

if-else statement

b.

Boolean method

d.

void method

28. Which of the following is the best type of tool to use to break up input validation into separate steps?

a.

Boolean method

c.

void method

b.

nested if statements

d.

none of these

29. When using the debugger, which command lets you execute a method call without seeing the individual statements within the method?

a.

Step Out

c.

Step Into

b.

Step Over

d.

Step Execute

30. When using the debugger, which command lets you follow a method call into the statements in the method's source code?

a.

Step Out

c.

Step Into

b.

Step Over

d.

Step Trace

31. When using the debugger, which command lets you immediately execute all remaining statements inside the current method and return to the method's caller?

a.

Step Out

c.

Step Into

b.

Step Over

d.

Step Trace

32. Which of the following data types can be returned from a method?

a.

int

b.

bool

c.

string

d.

any of these

Document Information

Document Type:
DOCX
Chapter Number:
6
Created Date:
Aug 21, 2025
Chapter Name:
Chapter 6 Modularizing Your Code With Methods
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