1. Back To Blog

.Net Interview Question:-Explain the procedure to declare Interfaces as private?

.Net Interview Question:-Explain the procedure to  declare Interfaces as private?

Sometimes I am surprised with some questions which come up during .NET interview and this one is one of them. I really do not understand why people ask such questions and how useful it is practically.

Most of the developers jump to the conclusion and say "NO".

Let me first prove that how the developer are also right by saying that Interfaces cannot be declared as private and later we will see that how they are also wrong(incorrect).

Now, let first declare an interface as private and try to compile it and see that what the compiler says about it.

In the above diagram you can see that the compiler throws an error saying that Elements defined in a namespace cannot be explicitly declared as private.

Now, let's prove the second point that interfaces can also be declared as private.

In the below code snippet you will see that I have declared the interface as private and try to build the solution, will see that what the compiler has to say about it.

In above diagram you can see that now the compiler has successfully build solution without throwing the error this means that we can declare Interfaces as private also but the interfaces declared as private should be declared inside the class.

Note: - To declare Interfaces as Private you need to declare it inside the class.


Following is the video which shows that how the questions are asked C#    and .NET interviews.

Please click here to see more Dotnet interview questions and answers


Visit Authors blog for more Most asked Dotnet interview questions

Shiv Prasad Koirala

Visit us @ www.questpond.com or call us at 022-66752917... read more

We are on Social