C# - Interfaces Question and Answer

C# - Interfaces Question and Answer
11. Which of the following can implement an interface?

    Data
    Class
    Enum
    Structure
    Namespace

  • 1, 3
  • 2, 4
  • 3, 5
  • 4 only
Show Answer
12. 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
    }
}

  • Class MyClass is an abstract class.
  • Class MyClass cannot contain instance data.
  • Class MyClass fully implements the interface IMyInterface.
  • Interface IMyInterface should be inherited from the Object class.
Show Answer
13. 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();
}

  • Properties cannot be declared inside an interface.
  • This is a perfectly workable interface.
  • The properties in the interface must have a body.
  • Subroutine in the interface must have a body.
Show Answer
Questions and Answers for Competitive Exams Various Entrance Test