Class declarations and object modeling: Correct Solution


Translate the specification below into an idiomatic Java class definition.

(In this context, "idiomatic" means following the common style and conventions of the language.)

  1. One kind of thing that exists in our model is an UndLapol.

  2. All UndLapols share a single PORAN_FIPO, which is an int. It is a constant. Its value is 4. Other classes cannot see its value.

Solution

public class UndLapol {
    public final int PORAN_FIPO = 4;

    public UndLapol() {
    }
}

Things to check in your solution:

Acceptable variations in the solution:


Related puzzles: