Tuesday 22 March 2011

Access specifiers interview questions

What are the access-specifiers available in c#?
There are 5 access specifiers.
Private, Protected, Public, Internal, Protected Internal.


Are private class-level variables inherited?
Yes, but they are not accessible.

Explain about Protected and protected internal, “internal” access-specifier?
protected - Access is limited to the containing class or types derived from the containing class.

internal - Access is limited to the current assembly.

protected internal - Access is limited to the current assembly or types derived from the containing class.

When you inherit a protected class-level variable, who is it available to?
Classes in the same namespace.

Explain public and private access specifier?
public: can be accessed anywhere

private: can be accessed in the class in which it is declared.

No comments:

Post a Comment