Properties

Q1: 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?

A Declare age property with only get accessor.

B Declare age property with only set accessor.

C Declare age property with both get and set accessors.

D Declare age property with get, set and normal accessors.

E None of the above

ANS:B - Declare age property with only set accessor.

No answer description is available. Let's discuss.



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.