logo

CuriousTab

CuriousTab

Discussion


Home C# Programming Polymorphism See What Others Are Saying!
  • Question
  • In order for an instance of a derived class to completely take over a class member from a base class, the base class has to declare that member as


  • Options
  • A. new
  • B. base
  • C. virtual
  • D. overrides
  • E. overloads

  • Correct Answer
  • virtual 


  • More questions

    • 1. Which of the following statements are correct about a HashTable collection?

      1. It is a keyed collection.
      2. It is a ordered collection.
      3. It is an indexed collection.
      4. It implements a IDictionaryEnumerator interface in its inner class.
      5. The key - value pairs present in a HashTable can be accessed using the Keys and Values properties of the inner class that implements the IDictionaryEnumerator interface.

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

          int[] a = {11, 3, 5, 9, 4}; 
      1. The array elements are created on the stack.
      2. Refernce a is created on the stack.
      3. The array elements are created on the heap.
      4. On declaring the array a new array class is created which is derived from System.Array Class.
      5. Whether the array elements are stored in the stack or heap depends upon the size of the array.

    • Options
    • A. 1, 2
    • B. 2, 3, 4
    • C. 2, 3, 5
    • D. 4, 5
    • E. None of these
    • Discuss
    • 3. Which of the following statements are correct about arrays used in C#.NET?

      1. Arrays can be rectangular or jagged.
      2. Rectangular arrays have similar rows stored in adjacent memory locations.
      3. Jagged arrays do not have an access to the methods of System.Array Class.
      4. Rectangular arrays do not have an access to the methods of System.Array Class.
      5. Jagged arrays have dissimilar rows stored in non-adjacent memory locations.

    • Options
    • A. 1, 2
    • B. 1, 3, 5
    • C. 3, 4
    • D. 1, 2, 5
    • E. 4, 5
    • Discuss
    • 4. Which of the following statements are correct?

      1. A switch statement can act on numerical as well as Boolean types.
      2. A switch statement can act on characters, strings and enumerations types.
      3. We cannot declare variables within a case statement if it is not enclosed by { }.
      4. The foreach statement is used to iterate through the collection to get the desired information and should be used to change the contents of the collection to avoid unpredictable side effects.
      5. All of the expressions of the for statement are not optional.

    • Options
    • A. 1, 2
    • B. 2, 3
    • C. 3, 5
    • D. 4, 5
    • E. None of these
    • Discuss
    • 5. Which of the following are the correct ways to define an array of 2 rows and 3 columns?

      1. int[ , ] a;
        a = new int[2, 3]{{7, 1, 3},{2, 9, 6}};
      2. int[ , ] a;
        a = new int[2, 3]{};
      3. int[ , ] a = {{7, 1, 3}, {2, 9,6 }};
      4. int[ , ] a;
        a = new int[1, 2];
      5. int[ , ] a;
        a = new int[1, 2]{{7, 1, 3}, {2, 9, 6}};

    • Options
    • A. 1, 2 , 3
    • B. 1, 3
    • C. 2, 3
    • D. 2, 4, 5
    • E. 4, 5
    • Discuss
    • 6. Which of the following is the correct way to find out the index of the second 's' in the string "She sells sea shells on the sea-shore"?

    • Options
    • A.
      String str = "She sells sea shells on the sea-shore"; 
      int i;
      i = str.SecondIndexOf("s");
    • B.
      String str = "She sells sea shells on the sea-shore"; 
      int i, j;
      i = str.FirstIndexOf("s"); 
      j = str.IndexOf("s", i + 1);
    • C.
      String str = "She sells sea shells on the sea-shore"; 
      int i, j;
      i = str.IndexOf("s"); 
      j = str.IndexOf("s", i + 1);
    • D.
      String str = "She sells sea shells on the sea-shore"; 
      int i, j;
      i = str.LastIndexOf("s"); 
      j = str.IndexOf("s", i - 1);
    • E.
      String str = "She sells sea shells on the sea-shore"; 
      int i, j;
      i = str.IndexOf("S"); 
      j = str.IndexOf("s", i);
    • Discuss
    • 7. Which of the following statements is correct about the C#.NET program given below?

      namespace CuriousTabConsoleApplication
      {
          class Baseclass
          { 
              int i;
              public Baseclass(int ii)
              {
                  i = ii;
                  Console.Write("Base "); 
              } 
          } 
          class Derived : Baseclass
          {
              public Derived(int ii) : base(ii)
              {
                  Console.Write("Derived ");
              } 
          } 
          class MyProgram
          { 
              static void Main(string[ ] args)
              { 
                  Derived d = new Derived(10);
              } 
          } 
      }

    • Options
    • A. The program will work correctly only if we implement zero-argument constructors in Baseclass as well as Derived class.
    • B. The program will output: Derived Base
    • C. The program will report an error in the statement base(ii).
    • D. The program will work correctly if we replace base(ii) with base.Baseclass(ii).
    • E. The program will output: Base Derived
    • Discuss
    • 8. Multiple inheritance is different from multiple levels of inheritance.

    • Options
    • A. True
    • B. False
    • Discuss
    • 9. Which of the following is NOT a .NET Exception class?

    • Options
    • A. Exception
    • B. StackMemoryException
    • C. DivideByZeroException
    • D. OutOfMemoryException
    • E. InvalidOperationException
    • Discuss
    • 10. Which of the followings is the correct way to overload + operator?

    • Options
    • A.
      public sample operator + ( sample a, sample b )
    • B.
      public abstract operator + ( sample a, sample b)
    • C.
      public abstract sample operator + (sample a, sample b )
    • D.
      public static sample operator + ( sample a, sample b )
    • E. All of the above
    • Discuss


    Comments

    There are no comments.

Enter a new Comment