Click here to Skip to main content
15,901,001 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I took a short five minute quiz after watching a video on Software Development and I got one question wrong, but it won't show me the answer after I got it wrong. I chose function and that was incorrect.

Which of the following is used to manage and modify the content of variables in a class?

A. Object
B. Method
C. Property
D. Function

What I have tried:

I watched the MVA video on Software Development and got the question wrong.
Posted
Updated 22-Jan-17 19:19pm
Comments
PIEBALDconsult 22-Jan-17 20:12pm    
"Property" is the better answer. But it may still be a bad question

1 solution

It is not a good question. Let us see why.

1. Term function is not used in C#. It is replaced by term method. So that rules out last option.
2. Property is a way to encapsulate your private members. It helps hiding the class internals that are associated with the variable. It definitely is something that helps managing private members.
3. Method can of course be used to manipulate variables as well. But IMHO that is not really what their only purpose should be. I mean something like this would not really make much sense:

C#
public void SetSomeVariable(string valueToChange){
somePrivateString = valueToChange;
}


Hence, I would rule that out as well.
4. Object of a class is what is needed to access any non-static member of the class. It is a prerequisite if we are dealing with non static (instance) members.

Looking at above, I would say properties with objects are used to manage instance based private members.
 
Share this answer
 
Comments
Member 12962592 23-Jan-17 9:20am    
It's property. I took the quiz again and that's what it said it was. Thank you very much for your explanation.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900