You are designing a class for an application. You need to restrict the availability of the member variable accessCount to the base class and to any classes that are derived from the base class. Which access modifier should you use?
Why Protected? Isn't Protected still available for derived classes? While we must restrict access for derived classes and to base class. And Private is accessible only in the same class or struct
The Answer should be protected. The statement mentions that "The member should be available to base class and ANY DERIVED classes".
If they would have said "NESTED DERIVED "Classes then Private is the correct answer.
see the below statement from this link https://docs.microsoft.com/en-us/dotnet/csharp/tutorials/inheritance :
Private members are visible only in derived classes that are nested in their base class. Otherwise, they are not visible in derived classes.
This section is not available anymore. Please use the main Exam Page.98-361 Exam Questions
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
cdc
Highly Voted 3 years, 1 month agoVarracosta
1 year, 7 months agovinx909
1 year, 3 months agoNamilopod
Most Recent 9 months agomisbelieving
9 months, 2 weeks agomk_dyn365
1 year, 2 months agosamkaas
2 years ago