Chapter 6

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

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

ANS: F

13. A __________ is a variable that receives an argument that is passed into a method. a. parameter b. argument c. reference d. none of these

ANS: A

14. 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 b. user friendly c. data bound d. identical to

ANS: A

17. A method containing a(n) ____________ allows you to specify which parameter variable the argument should be passed to. a. named argument b. dynamic parameter c. named constant d. alternative argument

ANS: A

21. ____________ are useful for returning more than one value from a method. a. Reference parameters b. Named arguments c. Default arguments d. Parameter lists

ANS: A

26. A value-returning statement must have a(n) ____________ statement. a. return b. assignment c. logical d. void

ANS: A

29. Which of the following is the best type of tool for breaking up input validation into separate steps? a. Boolean method b. nested if statement c. void method d. none of these

ANS: A

33. 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 b. step over c. step into d. step return

ANS: A

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 b. terminal c. value-returning d. private

ANS: A

7. The ____________ is a collection of statements that are performed when a method is executed. a. method body b. executable code c. method header d. method code listing

ANS: A

1. Dividing a large problem into several smaller problems that are easily solved is sometimes called ____________. a. programmatic simplification b. divide and conquer c. top down design d. parallel design

ANS: B

11. Programmers commonly use a technique known as ____________ to divide an algorithm into smaller parts, which are then implemented as methods. a. flowcharting b. top-down design c. modular prototyping d. subtask recognition

ANS: B

19. When an argument is ____________, only a copy of the argument's value is passed into the parameter variable. a. passed by reference b. passed by value c. named d. uninitialized

ANS: B

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

ANS: B

25. When a ____________ finishes, it returns a value to the statement that called it. a. public method b. value-returning method c. void method d. private method

ANS: B

28. You can use a(n) ____________ to test a conditional expression and return either true or false. a. reference parameter b. Boolean method c. if-else statement d. void method

ANS: B

31. When using the debugger, which command lets you execute a method call without seeing the individual statements within the method? a. step out b. step over c. step into d. step execute

ANS: B

9. Which one of the following statements correctly calls a method named ShowName? a. private void ShowName() b. ShowName(); c. Call.ShowName(); d. ShowName;

ANS: B

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 b. virtual break c. return point d. jump position

ANS: C

12. Data values passed a method when it is called are known as ____________. a. references b. variables c. arguments d. parameters

ANS: C

16. When a method contains multiple parameters, they are often referred to collectively as a(n) ____________. a. reference list b. parameter set c. parameter list d. argument list

ANS: C

18. 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 b. Boolean value c. default argument d. bitwise operator

ANS: C

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 b. method-based solution c. modularized program d. divisional program

ANS: C

23. 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 b. named argument c. output parameter d. named constant

ANS: C

32. When using the debugger, which command lets you follow a method call into the statements in the method's source code? a. step out b. step over c. step into d. step trace

ANS: C

5. When you call a ____________ method, it executes statements it contains and then returns a value back to the program statement that called it. a. recursive b. void c. value-returning d. public

ANS: C

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 b. lowercase characters c. Pascal case d. uppercase characters

ANS: C

15. A parameter variable's scope is the ____________ in which the parameter variable is declared. a. namespace b. class c. field d. method

ANS: D

20. 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 value b. a value parameter c. a variable parameter d. passed by reference

ANS: D

24. In C#, you declare an output parameter by writing the ____________ keyword before the parameter variable's data type. a. public b. ref c. const d. out

ANS: D

27. In a value-returning method, the type of data the method returns is commonly called the method's ____________. a. method value b. named type c. assigned value d. return type

ANS: D

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 the same task. a. code recylcing b. software engineering c. logic recycling d. code reuse

ANS: D

30. Which of the following data types can be returned from a method? a. int b. bool c. string d. any of these

ANS: D

6. The ____________, which appears at the beginning of a method definition, lists several important things about the method, including the method's name and list of parameters. a. method description b. method body c. method specification d. method header

ANS: D

13. The top-down design process is sometimes called stepwise engineering.

ANS: F

14. If you are writing a method and you want it to receive arguments when it is called, you must equip the method with one or more access modifiers.

ANS: F

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

ANS: F

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

ANS: F

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

ANS: F

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

ANS: F

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

ANS: F

3. Every method must have a nonempty parameter list.

ANS: F

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

ANS: F

31. Nested if statements can be useful for modularizing input validation.

ANS: F

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

ANS: F

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

ANS: F

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

ANS: F

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

ANS: F

11. Methods usually belong to a class, so you must write a method's definition inside the class to which it is supposed to belong.

ANS: T

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

ANS: T

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

ANS: T

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

ANS: T

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

ANS: T

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.

ANS: T

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

ANS: T

22. Default arguments must be literals or constants.

ANS: T

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

ANS: T

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

ANS: T

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

ANS: T

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

ANS: T

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

ANS: T

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

ANS: T

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

ANS: T

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

ANS: T

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

ANS: T

5. The statements that make up the method body are enclosed inside a set of curly braces.

ANS: T

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

ANS: T

8. In general, the same naming rules that apply to variables also apply to methods.

ANS: T

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

ANS: T


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

Unit 1 Microeconomics (Ch.1, Ch.2, Ch.3)

View Set

Compensation Administration - Chapter 17 Questions

View Set