1. Given the following, select how you would call the method. static void Perfor
ID: 3908350 • Letter: 1
Question
1. Given the following, select how you would call the method.
static void PerformCalculation();
int a = PerformCalculation();
PerformCalculation(4.45, 3.45);
void a = PerformCalculation();
PerforCalculation();
2. Variables defined inside of a method are ________________,
private variables
internal variables
local variables
public variables
3. Given the following code, select the value of the variable a when it is written to the console.
static void Main (string[] args){ int a = 3;
AddOne(a); a = a + 2;
Console.WriteLine(a);
} public int AddOne(ref int a) { return a++; }
6
3
4
5
4. Select the item that is not a modifier in C#:
Public
Int
Static
Protected
5. You should place modifiers after the return type when defining a method in C#.
True
False
6. Select a valid C# method that includes a call by reference parameter.
static void ref PerformCalculations(int a)
static void PerformCalculations(ByRef int a)
static void PerformCalculations(int a)
static void PerformCalculations(out int a)
7. Calls to ____ methods do not require instantiating an instance of the class to be used.
value returning
static
private
predefined
8. Select the access modifier to use if you do not require an instance of the class to call the particular method.
Public
Internal
Static
Void
9. Given the following code, what is the return type? static double PerformComplexMath(int a, int b);
Double
PerformComplexMath
Int
Public
10. Which keyword should you use in place of a return type to indicate that no value will be returned from a method?
Decimal
Public
Void
Const
Explanation / Answer
1. Given the following, select how you would call the method. PerformCalculation();
static void PerformCalculation();
int a = PerformCalculation();
PerformCalculation(4.45, 3.45);
void a = PerformCalculation();
PerformCalculation();
2. Variables defined inside of a method are local variables
internal variables
local variables
public variables
3. Given the following code, select the value of the variable a when it is written to the console. 5
static void Main (string[] args){ int a = 3;
AddOne(a); a = a + 2;
Console.WriteLine(a);
} public int AddOne(ref int a) { return a++; }
6
3
4
5
Explanation:
static void Main (string[] args){
int a = 3;
AddOne(a); //calls method public int AddOne(ref int a)
return a++; //a=3,a++ stores same value 3
a = a + 2; //a=3+5
Console.WriteLine(a); //prints 5
{ return a++; }
4. Select the item that is not a modifier in C#: Int
Public
Int
Static
Protected
Public,static,protected are acess modifiers in c#
5. You should place modifiers after the return type when defining a method in C#. False
True
False
6. Select a valid C# method that includes a call by reference parameter. static void PerformCalculations(out int a)
static void ref PerformCalculations(int a)
static void PerformCalculations(ByRef int a)
static void PerformCalculations(int a)
static void PerformCalculations(out int a)
7. Calls to static methods do not require instantiating an instance of the class to be used.
value returning
static
private
predefined
8. Select the access modifier to use if you do not require an instance of the class to call the particular method. Static
Public
Internal
Static
Void
9. Given the following code, what is the return type? static double PerformComplexMath(int a, int b); Double
Double
PerformComplexMath
Int
Public
10. Which keyword should you use in place of a return type to indicate that no value will be returned from a method? Void
Decimal
Public
Void
Const
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.