Why can?t you specify the accessibility modifier for methods
inside the interface?

Answers were Sorted based on User's Feedback



Why can?t you specify the accessibility modifier for methods inside the interface?..

Answer / tsahi

Interfaces are designed to make sure a class which
implements them exposes a certain set of methods. Because
these methods are exposed, they must be public. therefore,
there is no point in implementing a method from an interface
which will be anything other than public. So all methods in
an interface are always public.

Is This Answer Correct ?    5 Yes 0 No

Why can?t you specify the accessibility modifier for methods inside the interface?..

Answer / umesh

They all must be public. Therefore, to prevent you from
getting the false impression that you have any freedom of
choice, you are not allowed to specify any accessibility,
it?s public by default.

Is This Answer Correct ?    3 Yes 1 No

Why can?t you specify the accessibility modifier for methods inside the interface?..

Answer / lakshmi

Methods that implement an interface must be declared public. The reason for this is that methods are implicitly public within an interface, so their implementation must also public. Also the return type and signature of the implementing method must match exactly the return type and signature specified in the interface definition.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Sharp Interview Questions

What are modifiers in c#?

0 Answers  


What is type cast in C#?

0 Answers   TryTechnicals Pvt Ltd,


Why are strings immutable in c#?

0 Answers  


How do I count the length of a string in c#?

0 Answers  


Which technology is best for desktop application?

0 Answers  






Explain the Abstract class in c#.net

0 Answers  


what is the index value of the first element in an array?

0 Answers  


Explain manifest in c#.

0 Answers  


What are classes in c#?

0 Answers  


Can we instantiate abstract class in c#?

0 Answers  


What is difference between float and integer?

0 Answers  


Name the property of the textbox which cannot be changed at runtime?

0 Answers  


Categories