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 11 of 20

Explore more Topics under C# programming

Q101.
Select the statement which should be added to the current set of code to get the output as 10 20 ?
class baseclass
{
    protected int a = 20;
}
class derived : baseclass
{
    int a = 10;
    public void math()
    {
         /* add code here */
    }   
}
Discuss
Answer: (c).console.writeline(a + ” ” + base.a);
Q102.
Correct statement about the following C#.NET code is?
class baseclass
 {
     int a;
     public baseclass(int a1) 
     {
         a = a1;
         console.writeline(" a ");
     }
     class derivedclass : baseclass
     {
         public derivedclass (int a1) : base(a1)
         {
             console.writeline(" b ");
         }
     }
     class program
     {
         static void main(string[] args)
         {
             derivedclass d =  new derivedclass(20);
         }
     }
 }
Discuss
Answer: (c).Output : a
b
Q103.
Which statement should be added in function a() of class y to get output β€œi love csharp”?
class x
 {
     public void a()
     {
         console.write("bye");
     }
 }
 class y : x
 {
     public void a()
     {
     /* add statement here */
         console.writeline("  i love csharp ");
     }
 }
 class program
 {
     static void main(string[] args)
     {
         y obj =  new obj();
         obj.a();
     }
 }
Discuss
Answer: (c).base.a();
Discuss
Answer: (d).All of the mentioned
Q105.
Select the output for the following set of code?
class A 
{
    public int i;
    protected int j;
}    
class B : A 
{
    public int j;
    public void display() 
    {
        base.j = 3;
        Console.WriteLine(i + " " + j);
    }
}    
class Program
{
    static void Main(string[] args)
    {
        B obj = new B();
        obj.i = 1;
        obj.j = 2;
        obj.display();     
        Console.ReadLine();
    }
}
Discuss
Answer: (d).1 2
Q106.
Select the output of the following set of code?
class A
 {
     public int i;
     private int j;
 }     
 class B :A 
 {
     void display() 
     {
         base.j = base.i + 1;
         Console.WriteLine(base.i + "  " + base.j);
     }
}    
class Program
{
    static void Main(string[] args)
    {
        B obj = new B();
        obj.i = 1;
        obj.j = 2;
        obj.display();     
        Console.ReadLine();
    }
}
Discuss
Answer: (d).compile time error
Q107.
Which of these keywords is used to refer to member of base class from a sub class?
Discuss
Answer: (b).base
Q108.
Which of these operators must be used to inherit a class?
Discuss
Answer: (a).:
Q109.
What is the output of the following set of code ?
using System;
 public class BaseClass
 {
     public BaseClass()
     {
         Console.WriteLine("I am a base class");
     }
 }
 public class ChildClass : BaseClass
 {
     public ChildClass()
     {
         Console.WriteLine ("I am a child class");
     }
 static void Main()
 {
     ChildClass CC = new ChildClass();
 }
 }
Discuss
Answer: (a).I am a base class
I am a child class
Q110.
The process of defining two or more methods within the same class that have same name but different parameters list?
Discuss
Answer: (a).Method overloading

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!