C# Programming - Properties

Exercise :: Properties - General Questions

  • Properties - General Questions
16. 

Which of the folowing does an indexer allow to index in the same way as an array?

  1. A class
  2. A property
  3. A struct
  4. A function
  5. An interface

A. 1, 3, 5
B. 2, 4
C. 3, 5
D. 3, 4, 5

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

17. 

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

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

« Prev   1 2 3 4