Object-oriented programming (OOPs) Question:

Download Job Interview Questions and Answers PDF

What is Protected access modifier in C#?

OOP Interview Question
OOP Interview Question

Answer:

The protected keyword is a member access modifier. It can only be used in a declaring a function or method not in the class ie. a class can't be declared as protected class.

A protected member is accessible from within the class in which it is declared, and from within any class derived from the class that declare this member. In other words access is limited to within the class definition and any class that inherits from the class

A protected member of a base class is accessible in a derived class only if the access takes place through the derived class type.

Download OOP Interview Questions And Answers PDF

Previous QuestionNext Question
What is Protected Internal access modifier in C#?What is Internal access modifier in C#?