MCQOPTIONS
Saved Bookmarks
This section includes 2 Mcqs, each offering curated multiple-choice questions to sharpen your C# Questions & Answers Introduction of Properties knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
Consider a class maths and we had a property called as sum.b which is the reference to a maths object and we want the statement Console.WriteLine(b.sum)to fail. Which among the following is the correct solution to ensure this functionality? |
| A. | Declares sum property with only get accessor |
| B. | Declares sum property with only set accessor |
| C. | Declares sum property with both set and get accessor |
| D. | Declares sum property with both set, get and normal accessor |
| Answer» C. Declares sum property with both set and get accessor | |
| 2. |
Consider a class maths and we had a property called a sum.b is a reference to a maths object and we want the statement b.sum = 10 to fail. Which of the following is the correct solution to ensure this functionality? |
| A. | Declare sum property with both get and set accessors |
| B. | Declare sum property with only get accessor |
| C. | Declare sum property with get, set and normal accessors |
| D. | None of the mentioned |
| Answer» D. None of the mentioned | |