C# - Functions and Subroutines Questions and Answers

Take Exam

C# Functions and Subroutines questions with answers provide a strong foundation in modular programming. These programming questions and answers with explanations help learners differentiate between functions, subroutines, and methods, focusing on parameter passing, return types, and scope rules. Practicing C# programming MCQ or programming interview questions with answers improves coding confidence and interview readiness. Companies like IBM, Infosys, and TCS often include C# function-based problems in their placement tests. Regular practice ensures a clear understanding of reusable code structures, a key skill in professional C# development.

C# - Functions and Subroutines

Showing 10 of 29 questions

1. Which of the following statements are correct?     An argument passed to a ref parameter need not be initialized first.     Variables passed as out arguments need to be initialized prior to being passed.     Argument that uses params keyword must be the last argument of variable argument list of a method.     Pass by reference eliminates the overhead of copying large data items.     To use a ref parameter only the calling method must explicitly use the ref keyword.

  • 1, 2
  • 2, 3
  • 3, 4
  • 4, 5
Show Answer Report

2. A function returns a value, whereas a subroutine cannot return a value.

  • True
  • False
Show Answer Report

3. Which of the following statements are correct about functions and subroutines used in C#.NET?     A function cannot be called from a subroutine.     The ref keyword causes arguments to be passed by reference.     While using ref keyword any changes made to the parameter in the method will be reflected in that variable when control passes back to the calling method.     A subroutine cannot be called from a function.     Functions and subroutines can be called recursively.

  • 1, 2, 4
  • 2, 3, 5
  • 3, 5
  • 4, 5
Show Answer Report

4. Which of the following statements are correct?     C# allows a function to have arguments with default values.     C# allows a function to have variable number of arguments.     Omitting the return value type in method definition results into an exception.     Redefining a method parameter in the method's body causes an exception.     params is used to specify the syntax for a function with variable number of arguments.

  • 1, 3, 5
  • 3, 4, 5
  • 2, 5
  • 4, 5
Show Answer Report

5. Which of the following statements are correct about functions used in C#.NET?     Function definitions cannot be nested.     Functions can be called recursively.     If we do not return a value from a function then a value -1 gets returned.     To return the control from middle of a function exit function should be used.     Function calls can be nested.

  • 1, 2, 5
  • 2, 3, 5
  • 2, 3
  • 4, 5
Show Answer Report

6. How many values is a function capable of returning?

  • 1
  • 0
  • Depends upon how many params arguments does it use.
  • Any number of values.
Show Answer Report

7. How many values is a subroutine capable of returning?

  • Depends upon how many params arguments does it use.
  • Any number of values.
  • Depends upon how many ref arguments does it use.
  • 0
Show Answer Report

8. Which of the following CANNOT occur multiple number of times in a program?

  • namespace
  • Entrypoint
  • Class
  • Function
Show Answer Report

9. If a function fun() is to sometimes receive an int and sometimes a double then which of the following is the correct way of defining this function?

  • static void fun(object i) { ... }
  • static void fun(int i) { ... }
  • static void fun(double i, int j) { ... }
  • static void fun(int i, double j) { ... }
Show Answer Report

10. Which of the following statements are correct about subroutines used in C#.NET?     If we do not return a value from a subroutine then a value -1 gets returned.     Subroutine definitions cannot be nested.     Subroutine can be called recursively.     To return the control from middle of a subroutine exit subroutine should be used.     Subroutine calls can be nested.

  • 1, 2, 3
  • 2, 3, 5
  • 3, 5
  • 3, 4
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test