C# Programming - Interfaces
Exercise :: Interfaces - General Questions
- Interfaces - General Questions
6. |
Which of the following statements is correct about an interface used in C#.NET? |
A. |
If a class implements an interface partially, then it should be an abstract class. | B. |
A class cannot implement an interface partially. | C. |
An interface can contain static methods. | D. |
An interface can contain static data. | E. |
Multiple interface inheritance is not allowed. |
Answer: Option A
Explanation:
|
7. |
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: Option C
Explanation:
|
8. |
Which of the following statements are correct about an interface in C#.NET?
- A class can implement multiple interfaces.
- Structures cannot inherit a class but can implement an interface.
- In C#.NET, : is used to signify that a class member implements a specific interface.
- An interface can implement multiple classes.
- 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: Option A
Explanation:
|
9. |
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: Option D
Explanation:
|
10. |
Which of the following statements is correct? |
A. |
When a class inherits an interface it inherits member definitions as well as its implementations. | B. |
An interface cannot contain the signature of an indexer. | C. |
Interfaces members are automatically public. | D. |
To implement an interface member, the corresponding member in the class must be public as well as static. |
Answer: Option C
Explanation:
|