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 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.)

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;

7 Comments on “Which two actions should you perform?

  1. narcis says:

    I would say the question is not well made. If the property must be accessed AND modified only by the class members and derived types then E should be enough. But the text needs 2 answers and that’s why I don’t think the question is correct.
    The answer given is not correct as well since private setter will prevent the property to be modified by derived classes code.

    @jmcano: wrong, you can’t put two accessibility modifiers to get and set at the same time and any modifier must be more restrictive than the field modifier.




    6



    0
  2. sss says:

    The question is wrong. There is a part missing.
    The correct question was:

    The EmployeeType property value must be accessed only by code within the
    Employee class or within a class derived from the Employee class and modified only within the Employe class.

    Then, the correct answer is: BE

    protected string EmpType { get; private set;}

    this is a quite common way yo work with properties within base classes.




    12



    0
  3. Jean Maurice says:

    The question has parts missing and even the answer is totally wrong.

    It should be ‘accessed only by code within Employee class (or derived from employee class) and modified only within employee class’

    In which case it should be BE (protected get and private set)




    0



    0
  4. mytaiebh says:

    The right question is:
    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 class or 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.)




    0



    0

Leave a Reply