C# - Functions and Subroutines Questions and Answers
Practice ModeShowing 10 of 29 questions
Q21
Which type of method can be called without creating an instance of the class?
Answer: Option B
Explanation: Static methods belong to the class rather than instances.
Q22
What is the difference between a function and a subroutine in C#?
Answer: Option A
Explanation: In C#, all methods are essentially functions; void methods don't return values.
Q23
Which of the following is true about void methods?
Answer: Option C
Explanation: Void methods perform actions but don't return values.
Q24
What is the purpose of method parameters with default values?
Answer: Option B
Explanation: Default parameters allow calling methods without providing all arguments.
Q25
Which keyword is used to pass parameters by reference in C#?
Answer: Option B
Explanation: ref keyword passes variables by reference rather than by value.
Q26
What happens if a non-void method doesn't have a return statement?
Answer: Option C
Explanation: Non-void methods must return a value of the specified type.
Q27
Which of the following describes a static method?
Answer: Option C
Explanation: Static methods are called using the class name and don't require instances.
Q28
What is the scope of variables declared inside a method?
Answer: Option C
Explanation: Local variables are only accessible within the method they are declared.
Q29
Which of the following is an advantage of using methods?
Answer: Option C
Explanation: Methods promote code reusability and better organization.