Properties on C# related Questions and Answers


Question :   A Student class has a property called rollNo and stu is a reference to a Student object and we want the statement stu.RollNo = 28 to fail. Which of the following options will ensure this functionality?
1. Declare rollNo property with both get and set accessors.
2. Declare rollNo property with only set accessor.
3. Declare rollNo property with get, set and normal accessors.
4. Declare rollNo property with only get accessor.
Answer :   4 - Declare rollNo property with only get 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