Interfaces Questions
Practice Interfaces MCQs with answers and explanations. Page 1 of 1.
Category
C# Programming
Topic
Interfaces
Page
1 / 1
Mode
Practice
Questions
Open any question to view the answer and explanation.
C#.NET — Interfaces: choose the correct statement.
Open
View answer
C#.NET — Object size with only interface implementations: what is the instance size?
A class implements two interfaces (each with three methods) and has no instance fields. What is the size of an object created from this class?
Open
View answer
C#.NET — Interfaces: choose the correct statement about members and implementation.
Open
View answer
C#.NET — Which kinds of types can implement an interface?
Consider these candidates: (1) Data (n/a), (2) Class, (3) Enum, (4) Structure, (5) Namespace. Select all that can implement an interface.
Open
View answer
C#.NET — Interfaces: pick the single correct statement (clarifying implementation vs inheritance).
Open
View answer
C#.NET — Interface and class implementation details: analyze this code.
interface IMyInterface
{
void fun1();
int fun2();
}
class MyClass : IMyInterface
{
void fun1()
{ }
int IMyInterface.fun2()
{ return 0; }
}
Which statement best describes the situation?
Open
View answer
C#.NET — Which statements about interfaces are correct?
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 (by adding new implementing types without changing the interface).
Open
View answer
C#.NET — Which members can be declared inside an interface?
Consider: 1) Properties 2) Methods 3) Enumerations 4) Events 5) Structures
Open
View answer
C#.NET — Is the following interface definition valid?
interface IPerson
{
string FirstName { get; set; }
string LastName { get; set; }
void Print();
void Stock();
int Fun();
}
Open
View answer
C#.NET — Consider explicit interface implementation with a partially implemented interface.
interface IMyInterface { void fun1(); void fun2(); }
class MyClass : IMyInterface
{
private int i;
void IMyInterface.fun1() { /* code */ }
// fun2 not implemented here
}
What is correct?
Open
View answer
C#.NET — Choose the correct implementation for the interface:
interface IMyInterface { double MyFun(Single i); }
Open
View answer
C#.NET — Which statement about interfaces is correct?
Open
View answer
C#.NET — Which is a correct implementation of the IPerson interface?
interface IPerson { string FirstName { get; set; } }
Open
View answer
C#.NET — Which statement about interfaces is correct?
Open
View answer
C#.NET — Which statements about interfaces are correct?
1) A class can implement multiple interfaces.
2) Structures cannot inherit a class but can implement an interface.
3) In C#.NET, the colon (:) is used to signify that a class member implements a specific interface.
4) An interface can implement multiple classes.
5) The static modifier can be used on a method that implements an interface member.
Open
View answer
Practice smarter
Solve a few questions daily and revisit weak topics regularly to improve accuracy.