I retook the 8-question Enthuware test on 2 Nov 2026. Three of my attempt 1 misses are now fixed and three new rules caught me out. This page drills only those three rules, with new original questions. Every code sample was compiled and run on JDK 21.
| # | Rule tested | Result | vs attempt 1 |
|---|---|---|---|
| 1 | A permitted subtype must itself extend or implement the sealed type | ✗ | New miss → block 1 |
| 2 | Generic record patterns, no diamond, flow scope after || | ✓ | Fixed |
| 3 | Members a record gets automatically | ✓ | New, right first time |
| 4 | "Sealed" doesn't mean "can't be extended"; what can be sealed | ✗ | Repeat weak spot → block 2 |
| 5 | Records are final, nested records are static, and immutability is shallow | ✗ | New miss → block 3 |
| 6 | Compact plus normal canonical constructor is a duplicate | ✓ | Fixed |
| 7 | not recorded yet | – | |
| 8 | A record can have any number of overloaded constructors | ✓ | Fixed |
Recorded so far: 4 / 7. All three misses are about what the modifiers
sealed, non-sealed and final actually mean, and records are part of that.
permits X, and X must say extends/implements the parent. permits is a whitelist. It doesn't create the subtype relationship.permits doesn't extend or implement the parent, the error invalid permits clause is reported on the parent.final, sealed or non-sealed. A permitted interface must be sealed or non-sealed, because an interface can't be final. A record is already final.non-sealed is only allowed on a type whose direct supertype is sealed. sealed can go anywhere, including on a root class that extends only Object.permits can't name the sealed type in its own extends/implements, even if it already inherits it through a non-sealed class.permits without sealed is an error.final: no subclasses. sealed: only the permitted ones, and there must be at least one. non-sealed: anyone can extend it again.sealed. That excludes records, enums and annotation interfaces. Records and enums can still implement a sealed interface.permits clause, the permitted subtypes are the ones declared in the same file.sealed, non-sealed or abstract. Writing final record is redundant but legal.static is allowed on a member record but not on a local one.final, but a List, array or StringBuilder component can still be changed. For a deep copy, use items = List.copyOf(items); in a compact constructor.== is false and equals is true. Limiting instances is what enums do.implementsI thought being listed in permits made the class a subtype. It doesn't, so non-sealed class Result { } failed twice: the parent's permits clause was invalid, and non-sealed had no sealed parent to reopen.
It's false. A sealed class must be extended, but only by the types it permits. The answer was "none of the above", because the other options were also false: interfaces can be sealed, and records and enums can't be.
final = nobody · sealed = only the listed types · non-sealed = anyone again.Final, static when nested, and immutable (shallowly). They're not sealed, because a final type has no subtypes. They're also not about limiting the number of instances.
All three were right this time. They're still covered by blocks 2 and 5 on the attempt 1 page.
Work through blocks 1–4, then sit the timed mock. Reload the page to reshuffle. Aim for full marks on each block before you try the mock.
| Drill block | Qs | Last | Best | Runs | Last done |
|---|---|---|---|---|---|
| Loading… | |||||
Each statement on its own. This is the "give each option a yes or no" habit, which would have saved Q4 and Q5.
20 questions drawn at random from all the blocks above, with fresh question and option order every time. There's no feedback until you submit. You get 40 minutes, and the pass mark is 68%.