Question 1
By default, which TWO categories of throwable does Spring's declarative transaction management mark the transaction for rollback on? Select TWO.
A. RuntimeException and its subclasses (unchecked exceptions)Correct answer
An unchecked RuntimeException is the primary default rollback trigger: when one propagates out of the advised method, the transaction is marked rollback-only without any extra configuration.
B. Error and its subclasses (for example OutOfMemoryError)Correct answer
The default rule rolls back on Error as well as on RuntimeException — both are unchecked throwables, and either one propagating out of the method marks the transaction for rollback.
C. Checked exceptions such as IOException or SQLException
By default a checked exception lets the transaction commit rather than roll back; you must opt in explicitly with @Transactional(rollbackFor = ...) to make a checked exception trigger rollback.
D. Any exception type named in a noRollbackFor attribute
noRollbackFor does the opposite of triggering rollback: it removes the listed exception types from the rollback set so the transaction commits despite them.
Explanation
By default Spring's declarative transactions roll back on unchecked throwables: a RuntimeException (or any subclass) and an Error (or any subclass) each mark the transaction rollback-only when they propagate out of the advised method. A checked exception instead lets the transaction commit unless you opt in with @Transactional(rollbackFor = ...), and the noRollbackFor attribute removes exception types from the rollback set rather than adding them, so it never causes a rollback.