Vidyalelo
C# Programming · all questions

Functions and Methods in C Sharp
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

54

Questions

1/3

Page

Pick an option on a question to see the right answer and solution.

What is the keyword used to define a function in C#?

Select an option to see the answer and solution.

What is the purpose of a return type in a method declaration in C#?

Select an option to see the answer and solution.

In C#, which keyword is used to define a method that does not return a value?

Select an option to see the answer and solution.

What is the correct syntax to declare a method named Add that takes two integer parameters and returns their sum in C#?

Select an option to see the answer and solution.

Which of the following statements is true regarding method overloading in C#?

Select an option to see the answer and solution.

What is the purpose of the params keyword in C# method parameters?

Select an option to see the answer and solution.

What is the access modifier used to define a method that can be accessed from any class in the same assembly in C#?

Select an option to see the answer and solution.

Which of the following is NOT a valid parameter passing mechanism in C#?

Select an option to see the answer and solution.

What is the correct way to call a method named CalculateArea with parameters width and height in C#?

Select an option to see the answer and solution.

What is the result of the expression Math.Max(10, 20) in C#?

Select an option to see the answer and solution.

What is the purpose of the out keyword in C# method parameters?

Select an option to see the answer and solution.

In C#, which keyword is used to exit from a method without returning any value?

Select an option to see the answer and solution.

What is the correct way to define a method named PrintMessage that does not take any parameters and does not return any value in C#?

Select an option to see the answer and solution.

What is the purpose of method parameters in C#?

Select an option to see the answer and solution.

What is the correct way to define a method named GetSquare that takes an integer parameter num and returns its square in C#?

Select an option to see the answer and solution.

What is the purpose of the static keyword when applied to a method in C#?

Select an option to see the answer and solution.

What is the correct way to define a method named CalculateSum that takes two integers as parameters and returns their sum in C#?

Select an option to see the answer and solution.

In C#, which access modifier is used to restrict access to a method within the same class or derived classes?

Select an option to see the answer and solution.

What is the return type of a method that does not return any value in C#?

Select an option to see the answer and solution.

In C#, which keyword is used to define a method that belongs to a class and can be called without creating an instance of the class?

Select an option to see the answer and solution.