C# - Interfaces Questions and Answers
Practice ModeShowing 10 of 38 questions
Q11
Which of the following can implement an interface?
Data
Class
Enum
Structure
Namespace
Answer: Option B
Q12
Which of the following statements is correct about the C#.NET code snippet given below?
interface IMyInterface
{
void fun1();
void fun2();
}
class MyClass: IMyInterface
{
private int i;
void IMyInterface.fun1()
{
// Some code
}
}
Answer: Option
Q13
Which of the following statements is correct about the C#.NET code snippet given below?
interface IPerson
{
String FirstName
{
get;
set;
}
String LastName
{
get;
set;
}
void Print();
void Stock();
int Fun();
}
Answer: Option B
Q14
What is the primary purpose of an interface in C#
Answer: Option B
Explanation: Interfaces allow a class to implement multiple behaviors, supporting multiple inheritance.
Q15
Which keyword is used to define an interface in C#
Answer: Option C
Explanation: The interface keyword is specifically used to declare an interface.
Q16
Which member is allowed inside a C# interface
Answer: Option C
Explanation: Interfaces can only declare methods, properties, events, and indexers without implementation.
Q17
By default, members of an interface are
Answer: Option D
Explanation: All interface members are public by default and cannot use access modifiers.
Q18
Which of the following is true about interface methods
Answer: Option C
Explanation: A class implementing an interface must provide implementations for all its members.
Q19
How does a class implement an interface
Answer: Option C
Explanation: A class implements an interface using the colon : symbol.
Q20
Can an interface inherit another interface in C#
Answer: Option A
Explanation: Interfaces can inherit one or more interfaces.