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.
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
Explore more Topics under C# programming
public class maths
{
public int x;
public virtual void a()
{
}
}
public class subject : maths
{
new public void a()
{
}
}
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 ();
}
}
f2() of derived class get executed
f3() of base class get executed
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;
}
struct book
{
private String name;
private int pages;
private Single price;
}
book b = new book();
class trial
{
int i;
float d;
}
struct sample
{
private int x;
private Single y;
private trial z;
}
sample s = new sample();
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!