J.IX · Java 25 practice question

Inside a constructor epilogue (after super()), which form of the return statement is permitted in Java 25?

Choose one answer
Check answer and explanation

Correct answer: A bare return with no expression

Explanation

In a constructor epilogue, only a bare return with no expression is permitted; returning any expression is disallowed.

Common trap

Even though a constructor produces an instance of the class, returning this or any other expression is a compile-time error. Only the constructor prologue forbids return statements; the epilogue allows a bare return.

Source: JEP 513: Flexible Constructor Bodies — Description
Checked against the cited text on 2026-11-25.

Report an error in this question