Filters
Question type

Study Flashcards

What should you utilize when you don't know how many arguments you might eventually send to a method?


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

Correct Answer

verifed

verified

Write the DisplayStrings() method called in the code below using a parameter array declared in the method header.The method should write its arguments in a single line, followed by a newline.What will the output be after running Main()? using static System.Console; class ParamsDemo { static void Main() { string[] names = {"Mark", "Paulette", "Carol"}; DisplayStrings("Ginger"); DisplayStrings("George", "Maria", "Thomas"); DisplayStrings(names); } }

Correct Answer

verifed

verified

The DisplayStrings() method should be si...

View Answer

What is the difference between a reference parameter and an output parameter?

Correct Answer

verifed

verified

Reference and output parameters differ a...

View Answer

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

Correct Answer

verifed

verified

Suppose that you create overloaded method versions with the following declarations: private static void MyMethod(double d) private static void MyMethod(float f) Would MyMethod() run if it is called with an integer argument? Describe how C# determines which, if either, method should run when MyMethod() is called.

Correct Answer

verifed

verified

If you call MyMethod() using an integer ...

View Answer

Given the following two method signatures, explain the reasoning behind how the C# compiler determines which method version to invoke for the call MyMethod(12): private static void MyMethod(int a) private static void MyMethod(int a, char b = 'B')

Correct Answer

verifed

verified

If two signatures are equally good, the ...

View Answer

To ensure that the original value of an argument passed to a method remains unchanged after returning from the method, you should use a reference parameter or an output parameter.

Correct Answer

verifed

verified

False

What type of parameter requires that the argument used to call the method must have an assigned value?


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

Correct Answer

verifed

verified

What is a method considered to be when there is a potential for a situation in which the compiler cannot determine what method to use?


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

Correct Answer

verifed

verified

When adding optional parameters in a parameter list, what is a valid requirement?


A) The parameters must all be placed locally.
B) The parameters must appear to the right of all mandatory parameters.
C) The parameters must have constant values.
D) The parameters must be defined globally.

Correct Answer

verifed

verified

What type of parameter can be given a default value?


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

Correct Answer

verifed

verified

Under what circumstances can you return a reference from a method?


A) Only when the method performing the return is a static type method.
B) Only when the reference is for an array defined within the method's scope.
C) Only when a method is returning optional parameters with known values as the reference.
D) Only when it is safe to return, such as returning a reference from a method if the reference was passed into the method.

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

View Answer

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

Correct Answer

verifed

verified

When naming an argument in a method call using its parameter name, what must come before the value?


A) comma
B) dot
C) colon
D) semicolon

Correct Answer

verifed

verified

Describe the similarities and differences among method versions when the method is overloaded.

Correct Answer

verifed

verified

Methods are overloaded correctly when th...

View Answer

When declaring a method, how any params keywords are permitted?


A) Only as many as there will be arguments.
B) Only one params keyword is permitted.
C) Two, provided there is a nested method.
D) There is no limit to the use of the keyword.

Correct Answer

verifed

verified

What statement regarding reference parameters is accurate?


A) When you declare a reference parameter in a method header, the argument used to call the method does not require a value.
B) Reference parameters occupy their own memory locations.
C) Reference parameters act as aliases, or pseudonyms, for the same memory location occupied by the values passed to them.
D) The params keyword is used to indicate a reference parameter.

Correct Answer

verifed

verified

What Visual Studio IDE feature can be used to discover information about methods you are using?


A) CodeIntuit
B) IntelliSense
C) MagicMethod
D) BitDissect

Correct Answer

verifed

verified

B

What modifier is used to indicate that a parameter is used for output?


A) ref
B) params
C) get
D) out

Correct Answer

verifed

verified

D

Showing 1 - 20 of 39

Related Exams

Show Answer