C# Programming - Interfaces - Discussion

Discussion :: Interfaces - General Questions (Q.No.4)

4. 

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.
[E]. Interfaces cannot be inherited.

Answer: Option D

Explanation:

No answer description available for this question.

Venkatesh Bojja said: (Jul 20, 2012)  
public interface ISampleInterface
{
// Property declaration:
string Name
{
get;
set;
}
}

Properties can be used inside an interface. In the above example the accessor of an interface property does not have a body. Thus, the purpose of the accessors is to indicate whether the property is read-write, read-only, or write-only.

Bigc said: (Oct 15, 2012)  
Interfaces can't be inherited either, they are implemented which is a separate concept.

Ivy said: (Nov 6, 2013)  
Interfaces can be inherited :

interface IShape
{
void Show();
}

interface ITwoDShape : IShape
{
double Perimeter
{
get;
}
double Area
{
get;
}
}

interface IThreeDShape : IShape
{
double Volume
{
get;
}
}

interface IComparable
{
int CompareTo(Object obj);
}

Vijay Kumar Ray said: (Jul 10, 2016)  
Properties can be declared inside an interface is the right answer.

Kamal Pradhan said: (Nov 7, 2016)  
Properties, Methods and Events can be declared in an interface.

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.