Exam 8: Advanced Method Concepts

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

When you use a(n) ____ parameter in a method header, you indicate the parameter's type and name, and the method receives a copy of the value passed to it.

Free
(Multiple Choice)
4.7/5
(28)
Correct Answer:
Verified

D

Only ____ parameters can be given default values.

Free
(Multiple Choice)
4.9/5
(48)
Correct Answer:
Verified

A

Any optional parameters in a parameter list must appear to the right of all ____ parameters in the list.

Free
(Multiple Choice)
4.8/5
(36)
Correct Answer:
Verified

B

Methods with identical names that have identical parameter lists but different return types are ____ methods.

(Multiple Choice)
4.8/5
(38)

You cannot use the out or ref keywords when passing an array to a method.

(True/False)
4.8/5
(35)

____ parameters act as aliases, or pseudonyms, for the same memory location occupied by the original variable being passed to a method.

(Multiple Choice)
4.8/5
(35)

When you use the Visual Studio ____________________ to create programs, the IntelliSense feature will allow you to discover built-in overloaded methods by displaying all versions of the method when you type in the method name and the parameter list opening parenthesis.

(Short Answer)
4.8/5
(35)

A method's name and parameter list constitute the method's ____.

(Multiple Choice)
4.8/5
(32)

What is programming principle is violated when using named arguments and why is this important?

(Essay)
4.7/5
(38)

In C#, all data types are ____________________.

(Short Answer)
5.0/5
(37)

When you use a reference parameter, any passed variable must have an assigned value.

(True/False)
5.0/5
(39)

To avoid data conversion exceptions that occur when a value cannot be converted to an appropriate type, you can use a version of the C# ____ method with an out parameter.

(Multiple Choice)
4.8/5
(32)

Unnamed method arguments are also known as ____ arguments.

(Multiple Choice)
4.8/5
(33)

Given the following code, describe a situation that would make the code ambiguous to the C# compiler: using static System.Console; public class AmbiguousMethods { static void Main() { int iNum = 20; double dNum = 4.5; SimpleMethod(iNum, dNum); // calls first version SimpleMethod(dNum, iNum); // calls second version SimpleMethod(iNum, iNum); // error! Call is ambiguous. } private static void SimpleMethod( int i, double d) {       WriteLine("Method receives int and double"); } private static void SimpleMethod( double d, int i) {       WriteLine("Method receives double and int "); } }

(Essay)
4.9/5
(36)

In C#, parameters can be mandatory or ____.

(Multiple Choice)
4.8/5
(35)

On occasion, you might want a method to be able to alter a value you pass to it. In that case, you can use a(n) ____ parameter or an output parameter.

(Multiple Choice)
4.9/5
(28)

Given the following program, write the InputMethod() method. It should read two values from the user and assign them to the int variables first and second , which are then printed out in the code shown below. using static System.Console; class InputMethodDemo { static void Main() { int first, second; InputMethod( out first, out second);       WriteLine("After InputMethod first is {0}"), first);       WriteLine("and second is {0}"), second); } }

(Essay)
4.9/5
(35)

Methods are ____ when there is the potential for a situation in which the compiler cannot determine which method to use.

(Multiple Choice)
4.9/5
(25)

A method can return at most one value to a method that calls it.

(True/False)
4.9/5
(34)
Match each item with a statement below:
A parameter that receives a copy of the value passed to it
applicable methods
An argument in a calling method
implementation hiding
Named parameters can support this programming principle by providing clarity about the intended use of an argument
formal parameter
Correct Answer:
Verified
Premises:
Responses:
A parameter that receives a copy of the value passed to it
applicable methods
An argument in a calling method
implementation hiding
Named parameters can support this programming principle by providing clarity about the intended use of an argument
formal parameter
Declares a reference parameter
ref modifier
A programming principle compromised by named arguments
parameter array
A parameter in a method header
value parameter
A local array declared within the method header by using the keyword params
actual parameter
A set of methods that can accept a call given the passed argument list
self-documentation
Convenient when a variable might not have an assigned value when passed to a method
output parameter
(Matching)
4.8/5
(41)
Showing 1 - 20 of 42
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)