adplus-dvertising

Welcome to the Interfaces,Inheritance and Polymorphism MCQs Page

Dive deep into the fascinating world of Interfaces,Inheritance and Polymorphism with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Interfaces,Inheritance and Polymorphism, a crucial aspect of C# programming. In this section, you will encounter a diverse range of MCQs that cover various aspects of Interfaces,Inheritance and Polymorphism, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within C# programming.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Interfaces,Inheritance and Polymorphism. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of C# programming.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Interfaces,Inheritance and Polymorphism. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Interfaces,Inheritance and Polymorphism MCQs | Page 3 of 20

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

namespace CompSciBitsConsoleApplication
{ 
    class Baseclass
    { 
        public void fun()
        { 
            Console.Write("Base class" + " ");
        } 
    } 
    class Derived1: Baseclass
    { 
        new void fun()
        {
            Console.Write("Derived1 class" + " "); 
        } 
    } 
    class Derived2: Derived1
    { 
        new void fun()
        { 
            Console.Write("Derived2 class" + " ");
        }
    }
    class Program
    { 
        public static void Main(string[ ] args)
        { 
            Derived2 d = new Derived2(); 
            d.fun(); 
        } 
    } 
}
Discuss
Answer: (a).Base class
Q22.
Which of the following should be used to implement a 'Has a' relationship between two entities?
Discuss
Answer: (c).Containership
Q23.
Which of the following is correct about the C#.NET snippet given below?

namespace CompSciBitsConsoleApplication
{ 
    class Baseclass
    { 
        public void fun()
        { 
            Console.WriteLine("Hi" + " ");
        } 
        public void fun(int i)
        {
            Console.Write("Hello" + " ");
        } 
    } 
    class Derived: Baseclass
    {
        public void fun()
        {
            Console.Write("Bye" + " ");
        } 
    } 
    class MyProgram
    { 
        static void Main(string[ ] args)
        { 
            Derived d; 
            d = new Derived(); 
            d.fun(); 
            d.fun(77);
        } 
    } 
}
Discuss
Answer: (b).The program gives the output as: Bye Hello
Q24.
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
Discuss
Answer: (b).2, 5
Q25.
Which of the following are reuse mechanisms available in C#.NET?

1. Inheritance
2. Encapsulation
3. Templates
4. Containership
5. Polymorphism
Discuss
Answer: (a).1, 4
Q26.
Which of the following should be used to implement a 'Like a' or a 'Kind of' relationship between two entities?
Discuss
Answer: (b).Inheritance
Discuss
Answer: (c).Declare the class as sealed.
Q28.
Which of the following statements are correct about Inheritance in C#.NET?

1. A derived class object contains all the base class data.
2. Inheritance cannot suppress the base class functionality.
3. A derived class may not be able to access all the base class data.
4. Inheritance cannot extend the base class functionality.
5. In inheritance chain construction of object happens from base towards derived.
Discuss
Answer: (c).1, 3, 5
Discuss
Answer: (b).While creating the object firstly the constructor of class A will be called followed by constructor of class B.
Q30.
Which of the following statements is correct about the C#.NET program given below?

namespace CompSciBitsConsoleApplication
{
    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);
        } 
    } 
}
Discuss
Answer: (d).The program will output: Base Derived
Page 3 of 20

Suggested Topics

Are you eager to expand your knowledge beyond C# programming? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!