🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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?

  1. A.It is shared by all objects
  2. B.It is private: only code inside the class can read or change it
  3. C.It is a number
  4. 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 →