1
What is the keyword used to define a function in C#?
A)
function
B)
func
C)
method
D)
def
Answer & Solution
Answer: Option
C
2
What is the purpose of a return type in a method declaration in C#?
A)
To specify the access modifier of the method
B)
To specify the type of data returned by the method
C)
To specify the parameters of the method
D)
None of the above
Answer & Solution
Answer: Option
B
3
In C#, which keyword is used to define a method that does not return a value?
A)
return
B)
none
C)
void
D)
null
Answer & Solution
Answer: Option
C
4
What is the correct syntax to declare a method named Add that takes two integer parameters and returns their sum in C#?
A)
Add(int num1, int num2)
B)
int Add(num1, num2)
C)
Add(num1, num2)
D)
int Add(int num1, int num2)
Answer & Solution
Answer: Option
D
5
Which of the following statements is true regarding method overloading in C#?
A)
Methods must have the same return type and name
B)
Methods must have different return types
C)
Methods must have the same number of parameters
D)
Methods must have the same signature
Answer & Solution
Answer: Option
D
6
What is the purpose of the params keyword in C# method parameters?
A)
To specify that a method can accept a variable number of arguments
B)
To specify that a method can accept only one argument
C)
To specify that a method can accept no arguments
D)
To specify that a method can accept a fixed number of arguments
Answer & Solution
Answer: Option
A
7
What is the access modifier used to define a method that can be accessed from any class in the same assembly in C#?
A)
public
B)
private
C)
protected
D)
internal
Answer & Solution
Answer: Option
D
8
Which of the following is NOT a valid parameter passing mechanism in C#?
A)
Pass by reference
B)
Pass by value
C)
Pass by pointer
D)
Pass by output
Answer & Solution
Answer: Option
C
9
What is the correct way to call a method named CalculateArea with parameters width and height in C#?
A)
CalculateArea(width, height);
B)
CalculateArea(int width, int height);
C)
CalculateArea(10, 20);
D)
int result = CalculateArea(width, height);
Answer & Solution
Answer: Option
B
10
What is the result of the expression Math.Max(10, 20) in C#?
A)
10
B)
20
C)
Max
D)
20, 10
Answer & Solution
Answer: Option
B