logo

CuriousTab

CuriousTab

Discussion


Home C# Programming Functions and Subroutines See What Others Are Saying!
  • Question
  • Which of the following statements are correct about functions used in C#.NET?

    1. Function definitions cannot be nested.
    2. Functions can be called recursively.
    3. If we do not return a value from a function then a value -1 gets returned.
    4. To return the control from middle of a function exit function should be used.
    5. Function calls can be nested.


  • Options
  • A. 1, 2, 5
  • B. 2, 3, 5
  • C. 2, 3
  • D. 4, 5
  • E. None of these

  • Correct Answer
  • 1, 2, 5 


  • More questions

    • 1. Which of the following is the correct output of the C#.NET code snippet given below?

          int[ , , ] a = new int[ 3, 2, 3 ]; 
          Console.WriteLine(a.Length);

    • Options
    • A. 20
    • B. 4
    • C. 18
    • D. 10
    • E. 5
    • Discuss
    • 2. What will be the output of the code snippet given below?

      int i;
      for(i = 0; i<=10; i++)
      {
          if(i == 4)
          {
              Console.Write(i + " "); continue;
          }
          else if (i != 4)
              Console.Write(i + " "); else
          break;
      }

    • Options
    • A. 1 2 3 4 5 6 7 8 9 10
    • B. 1 2 3 4
    • C. 0 1 2 3 4 5 6 7 8 9 10
    • D. 4 5 6 7 8 9 10
    • E. 4
    • Discuss
    • 3. Which of the following statements are correct about a namespace used in C#.NET?

      1. Classes must belong to a namespace, whereas structures need not.
      2. Every class, struct, enum, delegate and interlace has to belong to some or the other namespace.
      3. All elements of the namespace have to belong to one file.
      4. If not mentioned, a namespace takes the name of the current project.
      5. The namespace should be imported to be able to use the elements in it.

    • Options
    • A. 1, 3
    • B. 2, 4, 5
    • C. 3, 5
    • D. 4 only
    • Discuss
    • 4. Which of the following are Logical operators in C#.NET?

      1. &&
      2. ||
      3. !
      4. Xor
      5. %

    • Options
    • A. 1, 2, 3
    • B. 1, 3, 4
    • C. 2, 4, 5
    • D. 3, 4, 5
    • E. None of these
    • Discuss
    • 5. Which of the following can be declared as a virtual in a class?

      1. Methods
      2. Properties
      3. Events
      4. Fields
      5. Static fields

    • Options
    • A. 1, 2, 3
    • B. 3, 5
    • C. 2, 4
    • D. 2, 3, 5
    • Discuss
    • 6. For the code snippet shown below, which of the following statements are valid?

      public class TestCuriousTab
      {
          public void TestSub<M> (M arg)
          {
              Console.Write(arg);
          }
      }
      class MyProgram
      {
          static void Main(string[] args)
          {
              TestCuriousTab tab = new TestCuriousTab();
              tab.TestSub("CuriousTab ");
              tab.TestSub(4.2f);
          }
      }

    • Options
    • A. Program will compile and on execution will print: CuriousTab 4.2
    • B. A non generic class Hello cannot have generic subroutine.
    • C. Compiler will generate an error.
    • D. Program will generate a run-time exception.
    • E. None of the above.
    • Discuss
    • 7. Which of the following modifier is used when a virtual method is redefined by a derived class?

    • Options
    • A. overloads
    • B. override
    • C. overridable
    • D. virtual
    • E. base
    • Discuss
    • 8. Which of the following statements is correct about constructors in C#.NET?

    • Options
    • A. A constructor cannot be declared as private.
    • B. A constructor cannot be overloaded.
    • C. A constructor can be a static constructor.
    • D. A constructor cannot access static data.
    • E. this reference is never passed to a constructor.
    • Discuss
    • 9. With which of the following can the ref keyword be used?

      1. Static data
      2. Instance data
      3. Static function/subroutine
      4. Instance function/subroutine

    • Options
    • A. 1, 2
    • B. 3, 4
    • C. 1, 3
    • D. 2, 4
    • E. All of the above
    • Discuss
    • 10. Which of the following are true about classes and struct?

      1. A class is a reference type, whereas a struct is a value type.
      2. Objects are created using new, whereas structure variables can be created either using new or without using new.
      3. A structure variable will always be created slower than an object.
      4. A structure variable will die when it goes out of scope.
      5. An object will die when it goes out of scope.

    • Options
    • A. 1, 2, 4
    • B. 3, 5
    • C. 2, 4
    • D. 3, 4, 5
    • Discuss


    Comments

    There are no comments.

Enter a new Comment