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

Discuss
Answer: (c).Both Constructors & Methods
Q112.
What could be the output of the following set of code?
class Program
 {
     static void Main(string[] args)
     {
         Console.WriteLine( vol(10));
         Console.WriteLine( vol(2.5f,  5));
         Console.WriteLine( vol( 5l,  4,  5));
         Console.ReadLine();
     }
     static int vol(int x)
     {
         return(x * x * x);
     }
     static float vol(float r,  int h)
     {
         return(3.14f * r * r * h);
     }
     static long vol(long l, int b, int h)
     {
         return(l * b * h);
     }
 }
Discuss
Answer: (d).1000
98.125
100
Q113.
What could be the output for the set of code?
class overload
  {
      public int x;
      int y;
      public int add(int a)
      {
          x = a + 1;
          return x;
      }
      public int add(int a, int b)
      {
          x = a + 2;
          return x;
      }
  }    
  class Program
  {
      static void Main(string[] args)
      {
          overload obj = new overload();
          overload obj1 = new overload();
          int a = 0;
          obj.add(6);
          obj1.add(6, 2);
          Console.WriteLine(obj.x);
          Console.WriteLine(obj1.x);
          Console.ReadLine();
      }
  }
Discuss
Answer: (d).7
8
Q114.
What will be the output for the set of code?
static void Main(string[] args)
 {
     int i = 5;
     int j  = 6;
     add(ref i);
     add(6);
     Console.WriteLine(i);
     Console.ReadLine();
 }
 static void add(ref int x)
 {
     x = x * x;
 }
 static void add(int x)
 {
     Console.WriteLine(x * x * x);
 }
Discuss
Answer: (d).216
25
Q115.
What would be output for the set of code?
class maths
 {
     public int x;
     public double y;
     public int add(int a, int b)
     {
         x = a + b;
         return x;
     }
     public int add(double c, double d)
     {
         y = c + d;
         return (int)y;
     }
     public maths()
     {
         this.x = 0;
         this.y = 0;
     }
 }    
class Program
{
    static void Main(string[] args)
    {
        maths obj = new maths();
        int a = 4;
        double b = 3.5;
        obj.add(a, a);
        obj.add(b, b);
        Console.WriteLine(obj.x + " " + obj.y);
        Console.ReadLine();
    }
}
Discuss
Answer: (d).8, 7
Q116.
What will be output for the given set of code?
class maths
 {
     public static void fun1()
     {
         Console.WriteLine("method 1 :");
     }
     public void fun2()
     {
         fun1();
         Console.WriteLine("method 2 :");
     }
     public void fun2(int k)
     {
         Console.WriteLine(k);
         fun2();
     }
 }    
 class Program
 {
     static void Main(string[] args)
     {
         maths obj = new maths();
         maths.fun1();
         obj.fun2(20);
         Console.ReadLine();
     }
 }
Discuss
Answer: (d).method 1:
20
method 1:
method 2:
Q117.
What is the process of defining a method in terms of itself, that is a method that calls itself?
Discuss
Answer: (d).Recursion
Q118.
What will be the output for the following set of code?
class maths
 {
     public int fun1(int k)
     {
         k = 20;
         return k;
     }
     public Single fun1(float t)
     {
         t = 3.4f;
         return t;
     }
 }  
 class Program
 {
     static void Main(string[] args)
     {
         maths obj = new maths();
         int i;
         i = obj.fun1(30);
         Console.WriteLine(i);
         Single j;
         j = obj.fun1(2.5f);
         Console.WriteLine(j);
         Console.ReadLine();
     }
 }
Discuss
Answer: (d).20
3.4f
Q119.
What will be the output for the given set of code?
class maths
 {
     public int fun(int k, int y)
     {
         return k + y;
     }
     public int fun1(int t, float z)
     {
         return (t+(int)z);
     }
 }    
 class Program
 {
     static void Main(string[] args)
     {
         maths obj = new maths();
         int i;
         int b = 90;
         int c = 100;
         int d = 12;
         float l = 14.78f;
         i = obj.fun(b, c);
         Console.WriteLine(i);
         int j = (obj.fun1(d,  l));
         Console.WriteLine(j);
         Console.ReadLine();
     }
 }
Discuss
Answer: (c).190, 26
Q120.
What will be the output for the set of code?
class maths
 {
     public int fun(int k, int y, int n)
     {
         Console.WriteLine(k + "  " + y + "  " + n);
         return (k);
     }
     public int fun1(int t,float z)
     {
         Console.WriteLine(t + "  " + z);
         return t;
     }
 }    
 class Program
 {
     static void Main(string[] args)
     {
         maths obj = new maths();
         int b = 90;
         int c = 100;
         int d ;
         float l;
         int i = obj.fun(b, c, 12);
         int j = (obj.fun1(12, 14.78f));
         Console.ReadLine();
     }
 }
Discuss
Answer: (d).90, 100, 12
12, 14.78

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!