Filters
Question type

Study Flashcards

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


A) overloaded
B) ambiguous
C) polymorphic
D) hidden

Correct Answer

verifed

verified

Unnamed method arguments are also known as ____ arguments.


A) self-documenting
B) optional
C) default
D) positional

Correct Answer

verifed

verified

Match each item with a statement below:

Premises
A parameter that receives a copy of the value passed to it
An argument in a calling method
Named parameters can support this programming principle by providing clarity about the intended use of an argument
Declares a reference parameter
A programming principle compromised by named arguments
A parameter in a method header
A local array declared within the method header by using the keyword params
A set of methods that can accept a call given the passed argument list
Convenient when a variable might not have an assigned value when passed to a method
Responses
applicable methods
implementation hiding
formal parameter
ref modifier
parameter array
value parameter
actual parameter
self-documentation
output parameter

Correct Answer

A parameter that receives a copy of the value passed to it
An argument in a calling method
Named parameters can support this programming principle by providing clarity about the intended use of an argument
Declares a reference parameter
A programming principle compromised by named arguments
A parameter in a method header
A local array declared within the method header by using the keyword params
A set of methods that can accept a call given the passed argument list
Convenient when a variable might not have an assigned value when passed to a method

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.


A) reference
B) output
C) input
D) value

Correct Answer

verifed

verified

D

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


A) Interface
B) Pointer
C) Reference
D) Value

Correct Answer

verifed

verified

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

Correct Answer

verifed

verified

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); } }

Correct Answer

verifed

verified

InputMethod( should be similar to the fo...

View Answer

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


A) return type
B) stamp
C) signature
D) type

Correct Answer

verifed

verified

In C#, parameters can be mandatory or ____.


A) optional
B) reference
C) output
D) value

Correct Answer

verifed

verified

In C#, all data types are ____________________.

Correct Answer

verifed

verified

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.


A) value
B) reference
C) optional
D) global

Correct Answer

verifed

verified

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.

Correct Answer

verifed

verified

IDE,integrated devel...

View Answer

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

Correct Answer

verifed

verified

A disadvantage to using named arguments ...

View Answer

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

Correct Answer

verifed

verified

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.


A) Convert()
B) ReadLine()
C) TryParse()
D) Parse()

Correct Answer

verifed

verified

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


A) local
B) mandatory
C) default
D) global

Correct Answer

verifed

verified

B

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


A) applicable
B) illegal
C) overloaded
D) related

Correct Answer

verifed

verified

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

Correct Answer

verifed

verified

Only ____ parameters can be given default values.


A) value
B) reference
C) output
D) array

Correct Answer

verifed

verified

A

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 "); } }

Correct Answer

verifed

verified

In the Main( method above, a call to Sim...

View Answer

Showing 1 - 20 of 42

Related Exams

Show Answer