logo

CuriousTab

CuriousTab

Discussion


Home C# Programming Functions and Subroutines See What Others Are Saying!
  • Question
  • A function can be used in an expression, whereas a subroutine cannot be.


  • Options
  • A. True
  • B. False

  • Correct Answer
  • True 


  • More questions

    • 1. An Employee class has a property called age and emp is reference to a Employee object and we want the statement Console.WriteLine(emp.age) to fail. Which of the following options will ensure this functionality?

    • Options
    • A. Declare age property with only get accessor.
    • B. Declare age property with only set accessor.
    • C. Declare age property with both get and set accessors.
    • D. Declare age property with get, set and normal accessors.
    • E. None of the above
    • Discuss
    • 2. Exceptions can be thrown even from a constructor, whereas error codes cannot be returned from a constructor.

    • Options
    • A. True
    • B. False
    • Discuss
    • 3. An object of a derived class cannot access private members of base class.

    • Options
    • A. True
    • B. False
    • Discuss
    • 4. Which of the following statements are correct about delegates?

    • Options
    • A. Delegates cannot be used to call a static method of a class.
    • B. Delegates cannot be used to call procedures that receive variable number of arguments.
    • C. If signatures of two methods are same they can be called through the same delegate object.
    • D. Delegates cannot be used to call an instance function. Delegates cannot be used to call an instance subroutine.
    • Discuss
    • 5. Which of the following statements are correct about constructors in C#.NET?

      1. Constructors cannot be overloaded.
      2. Constructors always have the name same as the name of the class.
      3. Constructors are never called explicitly.
      4. Constructors never return any value.
      5. Constructors allocate space for the object in memory.

    • Options
    • A. 1, 3, 5
    • B. 2, 3, 4
    • C. 3, 5
    • D. 4, 5
    • E. None of these
    • Discuss
    • 6. Which of the following statements is incorrect about a delegate?

    • Options
    • A. A single delegate can invoke more than one method.
    • B. Delegates can be shared.
    • C. Delegate is a value type.
    • D. Delegates are type-safe wrappers for function pointers.
    • E. The signature of a delegate must match the signature of the method that is to be called using it.
    • Discuss
    • 7. What will be the output of the C#.NET code snippet given below?

      namespace CuriousTabConsoleApplication
      {
          class Sample
          { 
              public static void fun1()
              { 
                  Console.WriteLine("CuriousTab1 method");
              }
              public void fun2()
              { 
                  fun1(); 
                  Console.WriteLine("CuriousTab2 method");
              }
              public void fun2(int i)
              { 
                  Console.WriteLine(i);
                  fun2(); 
              } 
          } 
          class MyProgram
          { 
              static void Main(string[ ] args)
              { 
                  Sample s = new Sample(); 
                  Sample.fun1(); 
                  s.fun2(123);
              } 
          } 
      }

    • Options
    • A.
      Tab1 method 
      123
      Tabl method 
      Tab2 method
    • B.
      Tab1 method 
      123
      Tab2 method
    • C.
      Tab2 method 
      123
      Tab2 method 
      Tabl method
    • D.
      Tabl method
      123
    • E.
      Tab2 method 
      123
      Tabl method
    • Discuss
    • 8. Which of the following is the correct way to implement a write only property Length in a Sample class?

    • Options
    • A.
      class Sample
      {
          public int Length
          {
              set
              {
                  Length = value;
              } 
          } 
      }
    • B.
      class Sample
      {
          int len;
          public int Length
          {
              get
              {
                  return len;
              }
              set
              {
                  len = value;
              } 
          } 
      }
    • C.
      class Sample
      {
          int len;
          public int Length
          {
              WriteOnly set
              {
                  len = value;
              } 
          } 
      }
    • D.
      class Sample
      {
          int len;
          public int Length
          {
              set
              {
                  len = value;
              }
          } 
      }
    • Discuss
    • 9. Which of the following statements are correct about an enum used in C#.NET?

      1. An enum can be declared inside a class.
      2. An enum can take Single, Double or Decimal values.
      3. An enum can be declared outside a class.
      4. An enum can be declared inside/outside a namespace.
      5. An object can be assigned to an enum variable.

    • Options
    • A. 1, 3, 4
    • B. 2, 5
    • C. 3, 4
    • D. 2, 4, 5
    • Discuss
    • 10. Which of the following is the necessary condition for implementing delegates?

    • Options
    • A. Class declaration
    • B. Inheritance
    • C. Run-time Polymorphism
    • D. Exceptions
    • E. Compile-time Polymorphism
    • Discuss


    Comments

    There are no comments.

Enter a new Comment