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

Explore more Topics under C# Programming

Q121.
What will be the output for the given set of code?
class maths
 {
     public int fun(int ii)
     {
         return(ii > 0 ? ii :ii * -1);
     }
     public long fun(long ll)
     {
         return(ll > 0 ? ll :ll * -1);
     }
     public double fun( double dd)
     {
         return(dd > 0 ? dd :dd * -1);
     }
 }    
 class Program
 {
     static void Main(string[] args)
     {
         maths obj = new maths();
         int i = -25;
         int j ;
         long l = -100000l ;
         long m;
         double d = -12.34;
         double e;
         j = obj.fun(i);
         m = obj.fun(l);
         e = obj.fun(d);
         Console.WriteLine(j + "  " + m + "  " + e);
         Console.ReadLine();
     }
 }
Discuss
Answer: (c).25 100000 12.34
Q122.
Which keyword is used to declare a base class method while performing overidding of base class methods?
Discuss
Answer: (b).virtual
Q123.
The process of defining a method in subclass having same name & type signature as a method in its superclass is known as?
Discuss
Answer: (b).Method overriding
Q124.
Which of the given modifiers can be used to prevent Method overriding?
Discuss
Answer: (c).Sealed
Discuss
Answer: (c).When overriding a method, the names and type signatures of the override method must be the same as the virtual method that is being overriden
Q126.
Which of the following cannot be used to declare a class as a virtual?
Discuss
Answer: (d).Fields
Q127.
What will be the output for the given set of code?
class A
 {
     public int i;
     public void display() 
     {
         Console.WriteLine(i);
     }
 }    
 class B: A 
 {
     public int j;
     public void display() 
     {
         Console.WriteLine(j);
     }
 }    
 class Program
 {
     static void Main(string[] args)
     {
         B obj = new B();
         obj.i = 1;
         obj.j = 2;
         obj.display();
         Console.ReadLine();
     }
 }
Discuss
Answer: (b).2
Q128.
What will be the output for the given set of code?
class A 
 {
     public virtual void display() 
     {
         Console.WriteLine("A");
     }    
 }    
 class B: A 
 {
    public override void display() 
    {
        Console.WriteLine(" B ");
    } 
 }    
class Program
{
    static void Main(string[] args)
    {
        A obj1 = new A();
        B obj2 = new B();
        A r;
        r = obj1;
        r.display();
        r = obj2;
        r.display();     
        Console.ReadLine();
    }
}
Discuss
Answer: (d).A, B
Q129.
The modifier used to hide the base class methods is ?
Discuss
Answer: (b).New
Q130.
To override a method in subclass, baseclass method should be defined as?
Discuss
Answer: (d).All of the mentioned

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!