Question 1
What is the role of a RowMapper passed to a JdbcTemplate query?
A. It converts the entire ResultSet into one object in a single call
Converting the whole ResultSet at once in a single call is the role of ResultSetExtractor, not RowMapper, which works one row at a time.
B. It supplies the SQL string the template will execute
A RowMapper does not define or supply SQL; the query string is passed separately to the JdbcTemplate method.
C. It opens and commits the surrounding database transaction
A RowMapper does not manage transactions; opening and committing the surrounding transaction is handled elsewhere, not by the row-mapping callback.
D. Its mapRow(rs, rowNum) is invoked once per row to convert that single ResultSet row into an objectCorrect answer
RowMapper is a per-row callback: JdbcTemplate invokes mapRow for each row, and the mapper reads columns from the current row and returns a domain object (Spring Framework 5.3 Reference, RowMapper / ResultSetExtractor).
Explanation
A RowMapper is a per-row mapping callback: the template invokes it once for each row of the ResultSet, and the mapper reads that single row's columns and returns a domain object. It is not responsible for consuming the entire ResultSet in one call (that is ResultSetExtractor's role), nor for supplying SQL or managing the surrounding transaction.