SQL for Java Devs interview questions
Batching, Indexes, JDBC, JOINs, PreparedStatements, Repository Pattern
172 questions with answers and explanations · 171 flashcards
Questions (page 4 of 4)
- How can you avoid the N+1 query problem when fetching orders and their items in a single transaction?Multiple choiceHard
- Which JDBC method is used to execute a SQL SELECT query and retrieve data?Multiple choiceMedium
- Which SQL clause is used to view the execution plan of a query in databases?Multiple choiceMedium
- Which JDBC method is used to execute a SQL SELECT query?Multiple choiceEasy
- Which method is used to add SQL statements to a batch in JDBC?Multiple choiceEasy
- What happens to the database state when executeBatch() is called without proper error handling, and one statement fails?Multiple choiceMedium
- In terms of performance, why might you choose to use a batch update with PreparedStatement?Multiple choiceMedium
- Why does using ResultSet.TYPE_SCROLL_INSENSITIVE when creating a ResultSet matter in practice?Multiple choiceHard
- Why is it recommended to use PreparedStatements instead of plain Statements for executing repeated queries?Multiple choiceEasy
- Which scenario would benefit most from using JDBC batch processing?Multiple choiceHard
- Which JDBC interface provides a way to execute parameterized SQL queries?Multiple choiceEasy
- When using a PreparedStatement, which of the following is a primary benefit over a Statement?Multiple choiceEasy
- Which JDBC component is responsible for holding data retrieved from a database?Multiple choiceEasy
- How can you ensure that two transactions don't interfere with each other in a Java e-commerce application?Multiple choiceHard
- Why is a repository method usually smaller than a full business transaction?Multiple choiceHard
- Which JDBC feature allows mapping SQL NULL values to Java null when retrieving column values?Multiple choiceHard
- Given tables 'customers' and 'orders', which SQL query correctly retrieves customers with their latest order?Multiple choiceHard
- How would you explain a key performance advantage of using PreparedStatements in JDBC in an interview?Multiple choiceMedium
- In JDBC, how can you optimize the performance of repeated database reads?Multiple choiceMedium
- When should you avoid using indexes in a database table?Multiple choiceMedium
- Which statement about using PreparedStatements in transactions is true?Multiple choiceMedium
- Why might a developer choose to use a PreparedStatement over a Statement in JDBC?Multiple choiceMedium