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 / swapna

They all must be public. Therefore, to prevent us from
getting the false impression that we have choice to access,
so we are not allowed to specify any accessibility, it's
public by default.

Is This Answer Correct ?    18 Yes 2 No

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

Answer / karans

All members of an interface is marked as public because :
1) If Private :- The members ca not be implemented into
child class (as private members are derived into child
class).
2). If Protected :- The members can not be accessed by
instance of the class implementing members of that
interface (as protected members become private into
inherited class) even the members will not be inherited
into other child classes of class implementing interface.
c). If Public :- The members can be implemented into
child classes and can be accessed by instances of that
class as well as can be inherited into child class of that
class.

So All the members of Interface are bydefault considered
as PUBLIC.

Is This Answer Correct ?    11 Yes 0 No

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

Answer / hafiz usman majeed

as by default public access is provided in c-sharp.net
classes and interfaces, and we use interfaces for
accompolishing the purpose of multiple inheritence we must
redefine all of the methods of interface in its inherited
class that implements it so all of these methods should be
publically accessible.

Is This Answer Correct ?    8 Yes 1 No

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

Answer / ravikiran gullapalli

Then How it can be called as interface,

Is This Answer Correct ?    5 Yes 1 No

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

Answer / kishore anumala

Always the access specifiers for the method in an interface
is public. We cannot implement the methods of interface if
the access specifier is other than public as we will be
left with errors like "members cannot access due to
protection level".

Is This Answer Correct ?    3 Yes 0 No

Post New Answer

More C Sharp Interview Questions

int i,string s, String s1 Which is valuetype which is refrence type.

6 Answers   Synechron, Sytel,


What is a long in c#?

0 Answers  


What is difference between array and list?

0 Answers  


Can we use "this" command within a static method?

0 Answers  


What are sorted lists?

0 Answers  






Why do we need properties in c#?

0 Answers  


Is there a way of specifying which block or loop to break out of when working with nested loops?

0 Answers  


What is the use of giving more than one CATCH BLOCK in one TRY block? Directly we can give that catch(Exception e)?Why we go for arrayoutofbound Exception,divided by zero etc..? Explain

2 Answers  


What is the difference between interface and abstract class ?

2 Answers   Basware, BITS,


What is the use of constructor in c# with example?

0 Answers  


Write an expression which satisfies the following statements: (i) Creates an object of type q (ii) If m is null, returns n, otherwise returns m (iii) If x and y are string types, it concatenates x and y

1 Answers  


When a switch is said to be congested?

0 Answers   Wipro,


Categories