About Getters and setters | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

About Getters and setters

Which is first executed setters or getters ?

22nd Oct 2019, 5:11 AM
Shahrukh Khan
Shahrukh Khan - avatar
5 Answers
+ 1
That's an curious question... what makes you ask it? those are methods, so the first one to be executed will depend on which one the rest of the code us calling first, right?
22nd Oct 2019, 5:19 AM
ifl
ifl - avatar
+ 1
Shahrukh Khan Getters will always work but it will return either null or 0 depends upon the datatype because you are not setting the value.
22nd Oct 2019, 7:15 AM
A͢J
A͢J - avatar
0
if you're talking about visual basics or c# component properties, definitely gets are executed before sets. Otherwise if you defined a function it depends which one you call.
22nd Oct 2019, 5:42 AM
George Samanlian
0
Will getters work without setters
22nd Oct 2019, 5:47 AM
Shahrukh Khan
Shahrukh Khan - avatar
0
if vb/c# properties yes. define your property as read only. it doesn't matter with other languages they'd be like any other function.
22nd Oct 2019, 5:51 AM
George Samanlian