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

Explore more Topics under C# Programming

Q171.
Correct way to implement the interface given below?
interface abc
   {
       string name
       {
           get;
           set;
       }
   }

a)
   class emp :employee
   {
       private string str;
       public string firstname;
       {
           get
           {
               return str;
           }
           set
           {
               str = value;
           }
       }
   }

b)
  class emp :implements person
  {
      private string str;
      public string firstname
      {
          get
          {
              return str;
          }
          set
          {
              str = value;
          }
      }
  }

c)
 class emp: implements person
 {
     private string str;
     public string person.firstname
     {
         get
         {
             return str;
         }
         set
         {
             str = value;
         }
     }
 }
Discuss
Answer: (a).a
Q172.
Choose the correct output of the following code snippet?
interface i1
 {
     void f1();
 }
 interface i2 :i1
 {
     void f2();
 }
 public class maths :i2
 {
     public void f2()
     {
         Console.WriteLine("fun2");
     }
     public void f1()
     {
         Console.WriteLine("fun1");
     }
 }
 class Program
 {
     static Void Main()
     {
         maths m = new maths();
         m.f1();
         m.f2();
     }
 }
Discuss
Answer: (c).fun1
fun2
Q173.
In order to avoid ambiguity among an interface derived from two base interfaces with same method name(and signature), the right code among the following given codes is?
a)

 interface i1
 {
     void m1();
 }
 interface i2
 {
     void m1();
 }
 interface i3 :i1, i2
 {
 }
 class c3 :i3
 {
     void i1.m1()
     {
     }
     void i1.m1()
     {
     } 
}

b)
 interface i1
 {
     void m1();
 }
     interface i2
     {
         void m1();
     }
     interface i3 :i1, i2
     {
     }
     class c3 :i3
     {
         void i1.i2.m1()
         {
         }
     }

c)
  interface i1
  {
      void m1();
  }
  interface i2
  {
      void m1();
  }
  interface i3 :i1, i2
  {
  }
  class c3 :i3
  {
      void i1.m1()
      {
      }
      void i2.m1()
      {
      }
  }
Discuss
Answer: (c).c
Q174.
Which of the following keyword is used to overload user defined types by defining static member functions?
Discuss
Answer: (c).operator
Discuss
Answer: (a).The conditional logical operators cannot be overloaded
Discuss
Answer: (b).โ€˜<<โ€˜ < โ€˜&โ€™ < โ€˜%โ€™ < โ€˜-โ€˜ < โ€˜/โ€™ < โ€˜+โ€™
Q177.
Operators that can be overloaded are?
Discuss
Answer: (b).โ€˜+=โ€™
Discuss
Answer: (d).All of the mentioned
Q179.
Correct way to define operator method or to perform operator overloading is?
Discuss
Answer: (c).public static retval operator op(arglist)
{

}
Discuss
Answer: (c).public static sample operator +(int a, int b)

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!