setMaxRows(2) method sets the limit for the maximum number of rows that any ResultSet object generated by this Statement object can contain to the specified number. If in case limit is exceeded then excess number of rows are dropped without intimating user.
Internally, prepStmt.setMaxRows(2); tells database that only 2 rows has to be fetched from database.
This query will fetch top 2 rows from oracle database.