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

Discuss
Answer: (d).None of the mentioned
Q52.
Select the sequence of execution of function f1(), f2() & f3() in C# .NET CODE?
class base
 {
     public void f1() {}
     public virtual void f2() {}
     public virtual  void f3() {}
 }
 class derived :base
 {
     new public void f1() {}
     public override void f2() {}
     public new void f3() {}
 } 
 class Program
 {
     static void Main(string[] args)
     {
         baseclass b = new derived();
         b.f1 ();
         b.f2 ();
         b.f3 ();
     }
 }
Discuss
Answer: (b).f1() of base class get executed
f2() of derived class get executed
f3() of base class get executed
Discuss
Answer: (c).By default methods are virtual
Q54.
Correct code to be added for overloaded operator – for C# .net code given below is?
class csharp
 {
     int x, y, z;
     public csharp()
     {
 
     }
     public csharp(int a ,int b ,int c)
     {
         x = a;
         y = b;
         z = c;
     }
     Add correct set of code here
    public void display()
    {
        console.writeline(x + "  " + y + "  " + z);
    }
    class program
    {
        static void Main(String[] args)
        {
            csharp s1 = new csharp(5 ,6 ,8);
            csharp s3 = new csharp();
            s3 = - s1;
            s3.display();
        }
    }
}

a)
 public static csharp operator -(csharp s1)
    {
        csharp t = new csharp();
        t.x = s1.x;
        t.y = s1.y;
        t.z = -s1.z;
        return t;
    }

b)
 public static csharp operator -(csharp s1)
    {
        csharp t = new csharp();
        t.x = s1.x;
        t.y = s1.y;
        t.z = s1.z;
        return t;
    }

c)
public static csharp operator -(csharp s1)
    {
        csharp t = new csharp();
        t.x = -s1.x;
        t.y = -s1.y;
        t.z = -s1.z;
        return t;
    }
Discuss
Answer: (c).c
Q55.
Selecting appropriate method out of number of overloaded methods by matching arguments in terms of number ,type and order and binding that selected method to object at compile time is called?
Discuss
Answer: (d).All of the mentioned
Discuss
Answer: (c).An abstract inherited property cannot be overridden in a derived class
Q57.
Which of the following is a correct statement about the C#.NET code given below?
struct book
{
    private String name;
    private int pages;
    private Single price;
}
book b = new book();
Discuss
Answer: (c).The structure variable ‘b’ will be created on the stack
Q58.
Which of the following is a correct statement about the C#.NET code given below?
class trial
{
    int i;
    float d;
}
struct sample
{
    private int x;
    private Single y;
    private trial z;
}
sample s = new sample();
Discuss
Answer: (d).s will be created on the stack
Discuss
Answer: (d).All of the mentioned
Discuss
Answer: (c).All of the mentioned
Page 6 of 20

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!