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

Q131.
What will be the output for the given set of code?
class a
 {
     public  void fun()
     {
         Console.WriteLine("base method");
     }
 }
 class b: a
 {
     public new void fun()
     {
         Console.WriteLine(" derived method ");
     }
 }
 class Program
 {
     static void Main(string[] args)
     {
         b k = new b();
         k.fun();
         Console.ReadLine();
     }
 }
Discuss
Answer: (b).Derived method
Q132.
What will be the output of the given set of code?
class maths
 {
     public int length;
     public int breadth;
     public maths(int x, int y)
     {
         length = x;
         breadth = y;
         Console.WriteLine(x + y);
     }
     public maths(double x, int y)
     {
         length = (int)x;
         breadth = y;
         Console.WriteLine(x * y);
     }
 }
class Program
{
    static void Main(string[] args)
    {
        maths m = new maths(20, 40);
        maths k = new maths(12.0, 12);
        Console.ReadLine();
    }
}
Discuss
Answer: (c).60, 144
Q133.
What will be the output of the given set of code?
class maths
 {
     public int length;
     public int breadth;
     public  maths(int x)
     {
         length = x + 1;
     }
     public maths(int x, int y)
     {
         length = x + 2;
     }
 }
 class Program
 {
     static void Main(string[] args)
     {
         maths m = new maths(6);
         maths k = new maths(6, 2);
         Console.WriteLine(m.length);
         Console.WriteLine(k.length);
         Console.ReadLine();
     }
 }
Discuss
Answer: (d).7, 8
Q134.
What will be the output of the given set of code?
class maths
 {
     public maths()
     {
         Console.WriteLine("constructor 1 :");
     }
     public maths(int x)
     {
         int p = 2;
         int u;
         u = p + x;
         Console.WriteLine("constructor 2: " +u);
     }
 }
 class Program
 {
     static void Main(string[] args)
     {
         maths k = new maths(4);
         maths t = new maths();
         Console.ReadLine();
     }
 }
Discuss
Answer: (c).constructor 2: 6
constructor 1:
Q135.
What will be the output of the given set of code?
class maths
{
    int i;
    public maths(int x)
    {
        i = x;
        Console.WriteLine(" hello: ");
    }
}
class maths1 : maths
{
    public  maths1(int x) :base(x)
    {
        Console.WriteLine("bye");
    }
}
class Program
{
    static void Main(string[] args)
    {
        maths1 k = new maths1(12);
        Console.ReadLine();
    }
}
Discuss
Answer: (a).hello bye
Q136.
What will be the output of the given set of code?
class maths
 {
     int i;
     public maths(int ii)
     {
         ii = 12;
         int j = 12;
         int r = ii * j;
         Console.WriteLine(r);
     }
 }
 class maths1 : maths
 {
     public maths1(int u) :base(u)
     {
         u = 13;
         int h = 13;
         Console.WriteLine(u + h);
     }
 }
 class maths2 : maths1
 {
     public maths2(int k) :base(k)
     {
         k = 24;
         int o = 6 ;
         Console.WriteLine(k /o);
     }
 }
 class Program
 {
     static void Main(string[] args)
     {
         maths2 t = new maths2(10);
         Console.ReadLine();
     }
 }
Discuss
Answer: (c).144, 26, 4
Q137.
Which keyword is used to refer baseclass constructor to subclass constructor?
Discuss
Answer: (c).Base
Q138.
When we call a constructor method among different given constructors. We match the suitable constructor by matching the name of constructor first , then the number and then the type of parameters to decide which constructor is to be overloaded.The process is also known as?
Discuss
Answer: (c).Polymorphism
Discuss
Answer: (c).Overloaded constructors can have different type of number of arguments as well as differ in number of arguments
Q140.
What will be the output of the given set of code?
class maths
  {
      static maths()
      {
          int s = 8;
          Console.WriteLine(s);
      }
      public  maths(int f)
      {
          int h = 10;
          Console.WriteLine(h);
      }
  }
  class Program
  {
      static void Main(string[] args)
      {
          maths p = new maths(0);
          Console.ReadLine();
      }
  }
Discuss
Answer: (c).8, 10

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!