Q.1

There is no private or protected inheritance in C#.NET.

  • True
  • False
Q.2

We can derive a class from a base class even if the base class's source code is not available.

  • True
  • False
Q.3

Assume class B is inherited from class A. Which of the following statements is correct about construction of an object of class B?

  • While creating the object firstly the constructor of class B will be called followed by constructor of class A.
  • While creating the object firstly the constructor of class A will be called followed by constructor of class B.
  • The constructor of only class B will be called.
  • The constructor of only class A will be called.
  • The order of calling constructors depends upon whether constructors in class A and class B are private or public.
Q.4

In an inheritance chain which of the following members of base class are accessible to the derived class members?

  1. static
  2. protected
  3. private
  4. shared
  5. public
  • 1, 3
  • 2, 5
  • 3, 4
  • 4, 5
Q.5

What will be the size of the object created by the following C#.NET code snippet?

namespace IndiabixConsoleApplication
{ 
    class Baseclass
    {
        private int i; 
        protected int j; 
        public int k;
    }
    class Derived: Baseclass
    {
        private int x; 
        protected int y; 
        public int z;
    }
    class MyProgram
    { 
        static void Main (string[ ] args)
        { 
            Derived d = new Derived();
        } 
    } 
}
  • 24 bytes
  • 12 bytes
  • 20 bytes
  • 10 bytes
  • 16 bytes
Q.6

Which of the following statements is correct about the C#.NET program given below?

namespace IndiabixConsoleApplication
{
    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);
        } 
    } 
}
  • The program will work correctly only if we implement zero-argument constructors in Baseclass as well as Derived class.
  • The program will output: Derived Base
  • The program will report an error in the statement base(ii).
  • The program will work correctly if we replace base(ii) with base.Baseclass(ii).
  • The program will output: Base Derived
Q.7

Which of the following are reuse mechanisms available in C#.NET?

  1. Inheritance
  2. Encapsulation
  3. Templates
  4. Containership
  5. Polymorphism
  • 1, 4
  • 1, 3
  • 2, 4
  • 3, 5
Q.8

Which statement will you add in the function fun() of class B, if it is to produce the output "Welcome to IndiaBIX.com!"?

namespace IndiabixConsoleApplication
{ 
    class A
    {
        public void fun()
        {
            Console.Write("Welcome");
        } 
    } 
    class B: A
    {
        public void fun()
        {
            // [*** Add statement here ***]
            Console.WriteLine(" to IndiaBIX.com!");
        } 
    } 
    class MyProgram
    { 
        static void Main (string[ ] args)
        { 
            B b = new B(); 
            b.fun();
        } 
    } 
}
  • base.fun();
  • A::fun();
  • fun();
  • mybase.fun();
  • A.fun();
0 h : 0 m : 1 s