Properties

Q1:
An Account class has a property called accountNo and acc is a reference to a bank object and we want the C#.NET code snippet given below to work. Which of the following options will ensure this functionality?
acc.accountNo = 10; 
Console.WriteLine(acc.accountNo);

A
Declare accountNo property with both get and set accessors.

B
Declare accountNo property with only get accessor.

C
Declare accountNo property with get, set and normal accessors.

D
Declare accountNo property with only set accessor.

E None of the above

ANS:A -

Declare accountNo property with both get and set accessors.

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.