Properties on C# related Questions and Answers


Question :   An Employee class has a property called age and emp is reference to a Employee object and we want the statement Console.WriteLine(emp.age) to fail. Which of the following options will ensure this functionality?
1. Declare age property with only get accessor.
2. Declare age property with only set accessor.
3. Declare age property with both get and set accessors.
4. Declare age property with get, set and normal accessors.
Answer :   2 - Declare age property with only set accessor.  

* Be the First to Post a Comment.

Submit comment :


Captcha Image
Reload

Ask Question

Captcha Image
Reload

Note : Name and Email never shown.





Subscribe


Become a part of EducationForever. Subscribe to our FREE Newsletter