logo

CuriousTab

CuriousTab

Discussion


Home C# Programming Classes and Objects See What Others Are Saying!
  • Question
  • Which of the following statements are correct about the this reference?

    1. this reference can be modified in the instance member function of a class.
    2. Static functions of a class never receive the this reference.
    3. Instance member functions of a class always receive a this reference.
    4. this reference continues to exist even after control returns from an instance member function.
    5. While calling an instance member function we are not required to pass the this reference explicitly.


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

  • Correct Answer
  • 2, 3, 5 


  • More questions

    • 1. What will be the output of the C#.NET code snippet given below?

      namespace CuriousTabConsoleApplication
      {
          class SampleProgram
          {
              static void Main(string[ ] args)
              {
                  int i = 5;
                  int j;
                  fun1(ref i);
                  fun2(out j);
                  Console.WriteLine(i + ", " + j);
              }
              static void funl(ref int x)
              {
                  x = x * x;
              }
              static void fun2(out int x)
              {
                  x = 6; 
                  x = x * x; 
              }
          }
      }

    • Options
    • A. 5, 6
    • B. 5, 36
    • C. 25, 36
    • D. 25, 0
    • E. 5, 0
    • Discuss
    • 2. Which of the following statements is correct about Interfaces used in C#.NET?

    • Options
    • A. All interfaces are derived from an Object class.
    • B. Interfaces can be inherited.
    • C. All interfaces are derived from an Object interface.
    • D. Interfaces can contain only method declaration.
    • E. Interfaces can contain static data and methods.
    • Discuss
    • 3. Which of the following statements is valid about advantages of generics?

    • Options
    • A. Generics shift the burden of type safety to the programmer rather than compiler.
    • B. Generics require use of explicit type casting.
    • C. Generics provide type safety without the overhead of multiple implementations.
    • D. Generics eliminate the possibility of run-time errors.
    • E. None of the above.
    • Discuss
    • 4. Which of the following is the correct way to implement a read only property Length in a Sample class?

    • Options
    • A.
      class Sample
      {
          int len;
          public int Length
          {
              get
              {
                  return len;
              } 
          } 
      }
    • B.
      class Sample
      {
          public int Length
          {
              get
              {
                  return Length;
              } 
          } 
      }
    • C.
      class Sample
      {
          int len;
          public int Length
          {
              get
              {
                  return len;
              } 
              set
              {
                  len = value;
              } 
          } 
      }
    • D.
      class Sample
      {
          int len;
          public int Length
          {
              Readonly get
              {
                  return len;
              } 
          } 
      }
    • Discuss
    • 5. Which of the following are necessary for Run-time Polymorphism?

      1. The overridden base method must be virtual, abstract or override.
      2. Both the override method and the virtual method must have the same access level modifier.
      3. An override declaration can change the accessibility of the virtual method.
      4. An abstract inherited property cannot be overridden in a derived class.
      5. An abstract method is implicitly a virtual method.

    • Options
    • A. 1, 3
    • B. 1, 2, 5
    • C. 2, 3, 4
    • D. 4 only
    • Discuss
    • 6. If s1 and s2 are references to two strings then which of the following are the correct ways to find whether the contents of the two strings are equal?

      1. if(s1 = s2)
      2. if(s1 == s2)
      3. int c;
        c = s1.CompareTo(s2);
      4. if( strcmp(s1, s2) )
      5. if (s1 is s2)

    • Options
    • A. 1, 2
    • B. 2, 3
    • C. 4, 5
    • D. 3, 5
    • Discuss
    • 7. Which of the following statements are correct about exception handling in C#.NET?

      1. If our program does not catch an exception then the .NET CLR catches it.
      2. It is possible to create user-defined exceptions.
      3. All types of exceptions can be caught using the Exception class.
      4. CLRExceptions is the base class for all exception classes.
      5. For every try block there must be a corresponding finally block.

    • Options
    • A. 1 and 2 only
    • B. 1, 2 and 3 only
    • C. 4 and 5 only
    • D. All of the above
    • E. None of the above
    • Discuss
    • 8. Which of the following statements is correct about the C#.NET code snippet given below?

          int[] intMyArr = {11, 3, 5, 9, 4}; 

    • Options
    • A. intMyArr is a reference to an object of System.Array Class.
    • B. intMyArr is a reference to an object of a class that the compiler derives from System.Array Class.
    • C. intMyArr is a reference to an array of integers.
    • D. intMyArr is a reference to an object created on the stack.
    • E. intMyArr is a reference to the array created on the stack.
    • Discuss
    • 9. Which of the following statements are correct about the this reference?

      1. this reference can be modified in the instance member function of a class.
      2. Static functions of a class never receive the this reference.
      3. Instance member functions of a class always receive a this reference.
      4. this reference continues to exist even after control returns from an instance member function.
      5. While calling an instance member function we are not required to pass the this reference explicitly.

    • Options
    • A. 1, 4
    • B. 2, 3, 5
    • C. 3, 4
    • D. 2, 5
    • E. None of these
    • Discuss
    • 10. A property can be declared inside a class, struct, Interface.

    • Options
    • A. True
    • B. False
    • Discuss


    Comments

    There are no comments.

Enter a new Comment