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?

- Online Exam Test Papers | - MCQs[multiple choice questions and answers ] | - Mock Test Papers | - Practice Papers | - Sample Test Papers |

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.


More MCQS Questions and answers

R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!