C# Programming - Properties - Discussion

Discussion Forum : Properties - General Questions (Q.No. 12)
12.
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);
Declare accountNo property with both get and set accessors.
Declare accountNo property with only get accessor.
Declare accountNo property with get, set and normal accessors.
Declare accountNo property with only set accessor.
None of the above
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
2 comments Page 1 of 1.

Nikki said:   1 decade ago
I am also agree with @Prasanna. If we use both properties any one can change the account number.

Prasanna said:   1 decade ago
Account number will not change for an account holder so it is only get accessor being used not both.

Post your comments here:

Your comments will be displayed after verification.