Exercise: Interfaces

Questions for: Interfaces

Which of the following is the correct implementation of the interface given below?
interface IMyInterface
{ 
    double MyFun(Single i);
}
A:
class MyClass
{
    double MyFun(Single i) as IMyInterface.MyFun
    {
        // Some code
    }
}
B:
class MyClass 
{
    MyFun (Single i) As Double
    {
        // Some code
    } 
}
C:
class MyClass: implements IMyInterface
{
    double fun(Single si) implements IMyInterface.MyFun()
    {
        //Some code
    } 
}
D:
class MyClass: IMyInterface
{
    double IMyInterface.MyFun(Single i)
    {
        // Some code
    } 
}
Answer: D
No answer description is available. Let's discuss.
Which of the following statements are correct about an interface in C#.NET?
  1. A class can implement multiple interfaces.
  2. Structures cannot inherit a class but can implement an interface.
  3. In C#.NET, : is used to signify that a class member implements a specific interface.
  4. An interface can implement multiple classes.
  5. The static attribute can be used with a method that implements an interface declaration.
A:
1, 2, 3
B:
2, 4
C:
3, 5
D:
None of the above.
Answer: A
No answer description is available. Let's discuss.
Which of the following statements is correct about an interface?
A:
One interface can be implemented in another interface.
B:
An interface can be implemented by multiple classes in the same program.
C:
A class that implements an interface can explicitly implement members of that interface.
D:
The functions declared in an interface have a body.
Answer: C
No answer description is available. Let's discuss.
Which of the following statements is correct about Interfaces used in C#.NET?
A:
All interfaces are derived from an Object class.
B:
Interfaces can be inherited.
C:
All interfaces are derived from an Object interface.
D:
Interfaces can contain only method declaration.
Answer: B
No answer description is available. Let's discuss.
Which of the following statements is correct about an interface used in C#.NET?
A:
One class can implement only one interface.
B:
In a program if one class implements an interface then no other class in the same program can implement this interface.
C:
From two base interfaces a new interface cannot be inherited.
D:
Properties can be declared inside an interface.
Answer: D
No answer description is available. Let's discuss.
Ad Slot (Above Pagination)
Quiz