← Quiz: Classes, Modules, Map and Set: all 10 questions
Quiz: Classes, Modules, Map and Set · Question 4 of 10
What is special about a field written as balance inside a class?
What is special about a field written as #balance inside a class?
- A.It is shared by all objects
- B.It is private: only code inside the class can read or change it
- C.It is a number
- D.It is exported from the module
Answer & explanation
Correct answer: It is private: only code inside the class can read or change it
Private fields give real encapsulation; using them outside the class is a syntax error.
Can you get the rest right without peeking?
Take the timed Quiz: Classes, Modules, Map and Set quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →