C# - Functions and Subroutines Questions and Answers

Practice Mode
Showing 10 of 29 questions
Q11
A function can be used in an expression, whereas a subroutine cannot be.
  • A TRUE
  • B FALSE
Answer: Option A
Q12
What is the primary purpose of a method in C#?
  • A To store data
  • B To organize code into reusable blocks
  • C To create variables
  • D To define classes
Answer: Option B
Explanation: Methods help organize code into reusable blocks and reduce redundancy.
Q13
Which keyword is used to define a method that does not return any value?
  • A null
  • B void
  • C empty
  • D none
Answer: Option B
Explanation: void keyword indicates no return value.
Q14
What is the correct syntax for defining a method in C#?
  • A method Name() {}
  • B returnType methodName() {}
  • C def methodName() {}
  • D function methodName() {}
Answer: Option B
Explanation: Method syntax requires return type, name, and parentheses for parameters.
Q15
Which of the following is true about method parameters?
  • A They are defined outside the method
  • B They act as variables that receive values
  • C They are always optional
  • D They cannot be used in the method body
Answer: Option B
Explanation: Parameters act as variables that receive values passed to the method.
Q16
What is method overloading in C#?
  • A Creating methods with different names
  • B Creating multiple methods with same name but different parameters
  • C Creating methods that override base class methods
  • D Creating methods with different return types only
Answer: Option B
Explanation: Overloading allows multiple methods with same name but different parameters.
Q17
Which keyword is used to call a method from another method?
  • A call
  • B invoke
  • C execute
  • D Simply use method name with parentheses
Answer: Option D
Explanation: Methods are called by using their name followed by parentheses.
Q18
What is the return type of a method that returns an integer value?
  • A void
  • B string
  • C int
  • D double
Answer: Option C
Explanation: int is the return type for integer values.
Q19
Which of the following is NOT a valid access modifier for methods?
  • A public
  • B private
  • C method
  • D protected
Answer: Option C
Explanation: public, private, and protected are valid access modifiers.
Q20
What is the purpose of the return statement in a method?
  • A To start the method
  • B To send a value back to the caller
  • C To create a loop
  • D To define variables
Answer: Option B
Explanation: return statement sends a value back to the caller and exits the method.
Questions and Answers for Competitive Exams Various Entrance Test