← Java from Scratch Lesson 36 of 88 · 10 XP

Modifiers

Theory and problem statement

Machine translation, not yet reviewed by a native speaker.

Access modifiers decide who can see a class member:

own class package subclass everyone
private ✔
(no keyword) ✔ ✔
protected ✔ ✔ ✔
public ✔ ✔ ✔ ✔

Other modifiers: - final — a variable can't be reassigned, a method can't be overridden, a class can't be inherited from (String is final); - static — belongs to the class, not to an object; - abstract — no implementation; the subclasses will provide it (the "Abstraction" lesson).

Task. The program doesn't compile — the compiler "guards" the modifiers. Fix it by changing only the modifiers in the class Config (don't touch the logic): - VERSION must stay a constant, but be readable from Main; - secret() is called from Main — make the method accessible; - limit is changed in Main — remove the ban on changing the field.

Sign up for free to solve this task right in your browser: code editor, running, test checks and hints.