PrepAway - Latest Free Exam Questions & Answers

Which two actions should you perform?

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 only by code within the Employee classor within a class
derived from the Employee class.
The EmployeeType property value must be modified only by code within the Employee classor
You need to ensure that the implementation of the EmployeeType property meets the requirements.
Which two actions should you perform? (Each correctanswer represents part of the complete solution.
Choose two.)

PrepAway - Latest Free Exam Questions & Answers

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;

Explanation:
BE protected string EmployeeType { get; private set; } is only correct answer
AB and AF would not compile because of error: Cannot specify accessibility modifiers for both accessors of the
property or indexer

18 Comments on “Which two actions should you perform?

  1. MarcoJacob says:

    It`s B and E.

    protected string EmployeeType { get; private set; }

    If you take A and F so you would receive an Error, because you cant use “protected” in an internal property. Also you don`t meet the requirement “The EmployeeType property value must be modified only by code within the Employee class” so the setter has to be “private”




    5



    0
  2. kubra says:

    I saw diffrent question.

    “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.”

    Result, Which two actions should you perform?




    0



    0

Leave a Reply