exam questions

Exam 70-483 All Questions

View all questions & answers for the 70-483 exam

Exam 70-483 topic 1 question 16 discussion

Actual exam question from Microsoft's 70-483
Question #: 16
Topic #: 1
[All 70-483 Questions]

You are creating a class named Employee. The class exposes a string property named EmployeeType. The following code segment defines the Employee class.
(Line numbers are included for reference only.)

The EmployeeType property value must be accessed and modified only by code within the Employee class or within a class derived from the Employee class.
You need to ensure that the implementation of the EmployeeType property meets the requirements.
Which two actions should you perform? (Each correct answer represents part of the complete solution. Choose two.)

  • A. Replace line 05 with the following code segment:protected get;
  • B. Replace line 06 with the following code segment:private set;
  • C. Replace line 03 with the following code segment:public string EmployeeType
  • D. Replace line 05 with the following code segment:private get;
  • E. Replace line 03 with the following code segment:protected string EmployeeType
  • F. Replace line 06 with the following code segment:protected set;
Show Suggested Answer Hide Answer
Suggested Answer: BE 🗳️

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
Mitsoshima
Highly Voted 6 years ago
How can you modify the property within a derived class, when the setter is private? --> Correct answer should oly be: E
upvoted 23 times
asdf652434
5 years, 9 months ago
true, but probably the question is wrong
upvoted 5 times
...
...
igorue190
Highly Voted 5 years, 10 months ago
The question is not formulated correctly, two different requirements two answers. ✑ The value must be accessed only by code within the Employee class or within a class derived from the Employee class - E ✑ The value must be modified only by code within the Employee class - B
upvoted 8 times
...
MDimitrov
Most Recent 4 years, 5 months ago
Because the question asks you to choose 2 answers, then correct is to choose protected get; protected set; Which is answers A and F. However, I think is more correct to ask you to choose one answer and it would be the answer C, which reads: protected string EmployeeType By creating a property as protected, it automatically creates their get; set; to be protected as well. So it satisfies the requirement.
upvoted 1 times
MDimitrov
4 years, 5 months ago
Typo: in the above comment I meant E, not C. protected string EmployeeType
upvoted 1 times
...
...
noussa
4 years, 5 months ago
The property EmployeeType is not protected it's INTERNAL: means accessible by any class within the assembly which doesn't meet the requirements in the question. A and F OR E: E satisfies all requirements but if you need to choose 2: A and F are good
upvoted 1 times
...
TomasRafaj
4 years, 5 months ago
If there is a requirement of choosing the 2 answers than it's A, F, but on the other hand I would choose only one which is E.
upvoted 2 times
...
Mogens
4 years, 5 months ago
It is B & F. A lot of the comments say that the question is wrong - why do you assume that the question is wrong instead of the answer ??
upvoted 1 times
...
SpaceBandit
4 years, 7 months ago
The question and answer is right. The answer lies in the "accessed and modified" which satisfies the "protected" and "private". protected = accessed ; private = modified. Hope this helps clarify.
upvoted 2 times
...
devpride
4 years, 8 months ago
I guess C & E are correct answer.
upvoted 1 times
...
Tumelo_M_Motloutsi
4 years, 11 months ago
The correct answer is E
upvoted 2 times
...
thiemamd
4 years, 11 months ago
The answer is only 'E'
upvoted 1 times
...
Oooo
4 years, 11 months ago
If it was asked to choose only one option, the correct answer it E. It suffices all the conditions. However as we are asked to choose two options- A and F form the correct combination of the solution. To all the people who are saying Private should be the answer please get your concepts cleared. Private can never be used anywhere other than its own class. The answer is A and F.
upvoted 5 times
noussa
4 years, 5 months ago
I totally agree. set should be protected and not private: A -F
upvoted 1 times
noussa
4 years, 5 months ago
I want just to Correct my answer: A-E are the correct ones. * protected: The type or member can be accessed only by code in the same class, or in a class that is derived from that class. * internal: The type or member can be accessed by any code in the same assembly, but not from another assembly.
upvoted 1 times
...
...
...
Ben1999
5 years ago
This question came up in my exam and asked for only one answer. Be careful!
upvoted 7 times
...
veroMarce
5 years, 1 month ago
Answer: B,E
upvoted 1 times
...
robinnirola
5 years, 2 months ago
Ans: B & E
upvoted 1 times
...
TonyBezerra
5 years, 4 months ago
To ensure that "must be accessed and modified only by code within the Employee class or within a class derived from the Employee class", the right answer must be A and F. https://docs.microsoft.com/pt-br/dotnet/csharp/programming-guide/classes-and-structs/access-modifiers
upvoted 2 times
sdGuru
5 years, 4 months ago
Cannot specify accessibility modifiers for both accessors of the property or indexer
upvoted 1 times
...
...
jose1024
5 years, 6 months ago
Within a derivated class you could do this.EmployeeType.Replace("a","b") which actually modifies the property value. What you cannot do is something like this.EmployeeType="b". I'm not native english so perhaps the difference is the word "modify". You can modify that property but can't "set" it.
upvoted 2 times
killerDJO
4 years, 9 months ago
Strings are read-only, so this will not modify property value.
upvoted 1 times
...
...
StudiousMCSD
5 years, 8 months ago
Question is wrong. It should read: The value must be accessed only by code within the Employee class or within a class derived from the Employee class. The value must be modified only by code within the Employee class.
upvoted 4 times
ArunPrem
5 years, 6 months ago
So as per the question that you mentioned in your comment, are you saying the correct answer is B,E? i.e. protected property, private member for the set?
upvoted 1 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 ...