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 is pure abstract class in c#?

0 Answers  


what kind of questions (.net)to expect in a telephonic interview.This is the first time i will be facing a tele interview .Any inputs regarding this??

2 Answers   iNube Software Solutions,


Does c# support c type macros?

0 Answers  


What is the difference between new and override in c#?

0 Answers  


Can you have more than one namespace in c#?

0 Answers  






Hello! How to do this: "Create manifest utility intended for creating update content files. Application should take a set of files as input parameter and generate XML based manifest file as output one." I use C# and vs.net 2003. It's urgent! Help please, thanks. Mayana

0 Answers  


What type of data type conversion happens when the compiler encounters the following code?

0 Answers  


Can we set image Source dynamically using C# in WPF application?

0 Answers   Tech Mahindra,


What can you do as a .net developer?

0 Answers  


What is architecture of your poroject? how i c an say?

2 Answers   Eminosoft, HCL, Phoenix Technologies,


Is comparator a functional interface?

0 Answers  


Is collection a data structure?

0 Answers  


Categories