exam questions

Exam 98-361 All Questions

View all questions & answers for the 98-361 exam

Exam 98-361 topic 2 question 4 discussion

Actual exam question from Microsoft's 98-361
Question #: 4
Topic #: 2
[All 98-361 Questions]

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?

  • A. Protected
  • B. Private
  • C. Public
  • D. Friend
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
cdc
Highly Voted 2 years, 6 months ago
The answer is Protected
upvoted 12 times
Varracosta
1 year, 1 month ago
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
upvoted 2 times
vinx909
8 months, 2 weeks ago
indeed derived classes do have access to it. " and to any classes that are derived from the base class.". that's what we are looking for.
upvoted 2 times
...
...
...
Namilopod
Most Recent 2 months ago
protected, not private
upvoted 2 times
...
misbelieving
2 months, 2 weeks ago
Definitely Protected!
upvoted 2 times
...
mk_dyn365
8 months ago
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.
upvoted 2 times
...
samkaas
1 year, 5 months ago
Protected
upvoted 4 times
...
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.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago