Inheritance

Q1:
Which of the following statements are correct about the C#.NET code snippet given below?
namespace AptitudeCrackConsoleApplication
{ 
    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.

A 1, 2, 5

B 2, 3, 4

C 3, 5

D 4, 5

E None of these

ANS:B - 2, 3, 4

No answer description is available. Let's discuss.



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.