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

Explore more Topics under C# Programming

Q141.
What will be the output of the given set of code?
class maths
{
    int i;
    public  maths(int ii)
    {
        ii = -25;
        int g;
        g = ii > 0 ? ii : ii * -1;
        Console.WriteLine(g);
    }
}
class maths1 :maths
{
    public  maths1(int ll) :base(ll)
    {
        ll = -1000;
        Console.WriteLine((ll > 0 ? ll : ll * -1));
    }
}
class Program
{
    static void Main(string[] args)
    {
        maths1 p = new maths1(6);
        Console.ReadLine();
    }
}
Discuss
Answer: (c).25
1000
Q142.
A type of class which does not have its own objects but acts as a base class for its subclass is known as?
Discuss
Answer: (c).Abstract class
Q143.
The modifier used to define a class which does not have objects of its own but acts as a base class for its subclass is?
Discuss
Answer: (d).Abstract
Discuss
Answer: (d).All of the mentioned
Q145.
What will be the output for the given set of code?
namespace ConsoleApplication4
 {   
     abstract class A 
     {
         int i;
         public  abstract void display();
     }    
     class B: A 
     {
         public  int j;
         public override void display() 
         {
             Console.WriteLine(j);
         }
     }    
     class Program
     {
         static void Main(string[] args)
         {
             B obj = new B();
             obj.j = 2;
             obj.display();
             Console.ReadLine();
         }
     }
 }
Discuss
Answer: (b).2
Q146.
What will be the output for the given set of code?
namespace ConsoleApplication4
 {
     abstract class A
     {
         public int i ;
         public int j ;
         public abstract void display();
     }    
     class B: A    
     {
         public int j = 5;
         public override void display() 
         {
             this.j = 3;
             Console.WriteLine(i + "  " + j);
         }
     }    
     class Program
     {
         static void Main(string[] args)
         {
             B obj = new B();
             obj.i = 1;
             obj.display();     
             Console.ReadLine();
         }
     }
 }
Discuss
Answer: (d).1, 3
Q147.
What will be the output for the given set of code?
namespace ConsoleApplication4
{   
    abstract class A 
    {
        public int i;
        public abstract void display();
    }    
    class B: A 
    {
        public  int j;
        public int sum;
        public override void display() 
        {
            sum = i + j;
            Console.WriteLine(+i + "\n" + +j);
            Console.WriteLine("sum is:" +sum);
        }
    }    
    class Program
    {
        static void Main(string[] args)
        {
            A obj = new B();
            obj.i = 2;
            B obj1 = new B();
            obj1.j = 10;
            obj.display();
            Console.ReadLine();
        }
    }
}
Discuss
Answer: (c).2, 0
2
Q148.
If a class inheriting an abstract class does not define all of its functions then it is known as?
Discuss
Answer: (a).Abstract
Q149.
Which of the following modifiers is used when an abstract method is redefined by a derived class?
Discuss
Answer: (b).Override
Q150.
What will be the output for the given set of code?
namespace ConsoleApplication4
 {
     public abstract class A
     {
         public int i = 7;
         public abstract void display();
     }    
     class B: A 
     {
         public int j;
         public override void display() 
         {
             Console.WriteLine(i);
             Console.WriteLine(j);
         }
     }    
     class Program
     {
         static void Main(string[] args)
         {
             B obj = new B();
             A obj1 = new B();
             obj.j = 1;
             obj1.i = 8;
             obj.display();
             Console.ReadLine();
         }
     }
 }
Discuss
Answer: (d).7, 1

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!