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 2 of 20
Explore more Topics under C# Programming
1. An interface can contain properties, methods and events.
2. The keyword must implement forces implementation of an interface.
3. Interfaces can be overloaded.
4. Interfaces can be implemented by a class or a struct.
5. Enhanced implementations of an interface can be developed without breaking existing code.
1. Data
2. Class
3. Enum
4. Structure
5. Namespace
interface IMyInterface
{
void fun1();
void fun2();
}
class MyClass: IMyInterface
{
private int i;
void IMyInterface.fun1()
{
// Some code
}
}
interface IPerson
{
String FirstName
{
get;
set;
}
String LastName
{
get;
set;
}
void Print();
void Stock();
int Fun();
}
interface IPerson
{
String FirstName
{
get;
set;
}
}
{
private String str;
public String FirstName
{
get
{
return str;
}
set
{
str = value;
}
}
}
1. Use the existing functionality of base class.
2. Overrride the existing functionality of base class.
3. Implement new functionality in the derived class.
4. Implement polymorphic behaviour.
5. Implement containership.
class BaseClass
{
protected int i = 13;
}
class Derived: BaseClass
{
int i = 9;
public void fun()
{
// [*** Add statement here ***]
}
}
1. count should be declared as public if it is to become available in the inheritance chain.
2. count should be declared as protected if it is to become available in the inheritance chain.
3. While constructing an object referred to by i firstly constructor of index class will be called followed by constructor of index1 class.
4. Constructor of index class does not get inherited in index1 class.
5. count should be declared as Friend if it is to become available in the inheritance chain.
namespace CompSciBitsConsoleApplication
{
class index
{
protected int count;
public index()
{
count = 0;
}
}
class index1: index
{
public void increment()
{
count = count +1;
}
}
class MyProgram
{
static void Main(string[] args)
{
index1 i = new index1();
i.increment();
}
}
}
namespace CompSciBitsConsoleApplication
{
class Baseclass
{
private int i;
protected int j;
public int k;
}
class Derived: Baseclass
{
private int x;
protected int y;
public int z;
}
class MyProgram
{
static void Main (string[ ] args)
{
Derived d = new Derived();
}
}
}
namespace CompSciBitsConsoleApplication
{
class A
{
public void fun()
{
Console.Write("Welcome");
}
}
class B: A
{
public void fun()
{
// [*** Add statement here ***]
Console.WriteLine(" to CompSciBits.com!");
}
}
class MyProgram
{
static void Main (string[ ] args)
{
B b = new B();
b.fun();
}
}
}
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!