logo

CuriousTab

CuriousTab

Discussion


Home C# Programming Inheritance See What Others Are Saying!
  • Question
  • Which of the following statements are correct about the C#.NET code snippet given below?

    namespace CuriousTabConsoleApplication
    { 
        class index
        {
            protected int count;
            public index()
            {
                count = 0;
            }
        }
        class index1: index
        {
            public void increment()
            {
                count = count +1;
            }
        }
        class MyProgram
        {
            static void Main(string[] args)
            {
                index1 i = new index1(); 
                i.increment(); 
            }
        }
    }
    1. count should be declared as public if it is to become available in the inheritance chain.
    2. count should be declared as protected if it is to become available in the inheritance chain.
    3. While constructing an object referred to by i firstly constructor of index class will be called followed by constructor of index1 class.
    4. Constructor of index class does not get inherited in index1 class.
    5. count should be declared as Friend if it is to become available in the inheritance chain.


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

  • Correct Answer
  • 2, 3, 4 


  • More questions

    • 1. Which of the following statements is correct about a namespace used in C#.NET?

    • Options
    • A. Nested namespaces are not allowed.
    • B. Importing outer namespace imports inner namespace.
    • C. Nested namespaces are allowed.
    • D. If nested, the namespaces cannot be split across files.
    • Discuss
    • 2. Which of the following does not store a sign?

    • Options
    • A. Short
    • B. Integer
    • C. Long
    • D. Byte
    • E. Single
    • Discuss
    • 3. Which of the following is NOT an Integer?

    • Options
    • A. Char
    • B. Byte
    • C. Integer
    • D. Short
    • E. Long
    • Discuss
    • 4. Which of the following is the root of the .NET type hierarchy?

    • Options
    • A. System.Object
    • B. System.Type
    • C. System.Base
    • D. System.Parent
    • E. System.Root
    • Discuss
    • 5. Which of the following is NOT a Bitwise operator in C#.NET?

    • Options
    • A. &
    • B. |
    • C. <<
    • D. ^
    • E. ~
    • Discuss
    • 6. Which of the following is the correct default value of a Boolean type?

    • Options
    • A. 0 
    • B. 1
    • C. True
    • D. False
    • E. -1
    • Discuss
    • 7. What will be the output of the C#.NET code snippet given below?

      byte b1 = 0xAB;
      byte b2 = 0x99;
      byte temp;
      temp = (byte)~b2;
      Console.Write(temp + " ");
      temp = (byte)(b1 << b2);
      Console.Write (temp + " ");
      temp = (byte) (b2 >> 2);
      Console.WriteLine(temp);

    • Options
    • A. 102 1 38
    • B. 108 0 32
    • C. 102 0 38
    • D. 1 0 1
    • Discuss
    • 8. A class D can be derived from a class C, which is derived from a class B, which is derived from a class A.

    • Options
    • A. True
    • B. False
    • Discuss
    • 9. What will be the output of the C#.NET code snippet given below?

      int val;
      for (val = -5; val <= 5; val++)
      {
          switch (val)
          {
              case 0:
                  Console.Write ("India"); 
                  break;
          }
          
          if (val > 0)
              Console.Write ("B"); 
          else if (val < 0)
              Console.Write ("X");
      }

    • Options
    • A. XXXXXIndia
    • B. IndiaBBBBB
    • C. XXXXXIndiaBBBBB
    • D. BBBBBIndiaXXXXX
    • E. Zero
    • Discuss
    • 10. Which of the following forms of applying an attribute is correct?

    • Options
    • A.
      < Serializable() > class sample
      { /* ... */ }
    • B.
      (Serializable()) class sample
      { /* ... */ }
    • C.
      [ Serializable() ] class sample
      { /* ... */ }
    • D.
      Serializablef) class sample
      { /* ... */ }
    • E. None of the above
    • Discuss


    Comments

    There are no comments.

Enter a new Comment