Programming in C# — Question 107

An application includes a class named Person. The Person class includes a method named GetData.
You need to ensure that the GetData() from the Person class.
Which access modifier should you use for the GetData() method?

Answer options

Correct answer: B

Explanation

The correct answer is B, Protected, as it allows access to the GetData() method within its own class and by derived classes. The other options have broader or narrower access levels that do not meet the requirement of restricting access to only derived classes.