SQL for Java Devs interview questions
Batching, Indexes, JDBC, JOINs, PreparedStatements, Repository Pattern
172 questions with answers and explanations · 171 flashcards
Questions (page 3 of 4)
- Why can JDBC batch processing if not carefully managed become a problem in production code?Multiple choiceMedium
- How can you safely execute a user-supplied search term in a SQL query using a PreparedStatement?Multiple choiceMedium
- What role does the JDBC DriverManager class play in a Java application?Multiple choiceMedium
- Which of the following best describes the role of a placeholder in a PreparedStatement?Multiple choiceEasy
- Why might a transaction fail in a JDBC application?Multiple choiceHard
- Which SQL keyword is used to combine rows from two or more tables based on a related column?Multiple choiceEasy
- Which interface does ResultSet implement?Multiple choiceEasy
- Which JDBC interface is responsible for managing database connections?Multiple choiceEasy
- How would you explain a placeholder in the context of a PreparedStatement in an interview?Multiple choiceEasy
- Which of the following is a key advantage of using PreparedStatement over Statement in JDBC?Multiple choiceEasy
- Which SQL statement can you use to create an index on the 'email' column of a 'users' table to speed up search queries?Multiple choiceEasy
- How would you explain the return type of the executeBatch() method in JDBC in an interview?Multiple choiceMedium
- Which of the following is a direct benefit of using JDBC batch processing for multiple inserts in a database?Multiple choiceEasy
- How do you safely extract an integer value from the 'quantity' column in a ResultSet?Multiple choiceMedium
- In a JDBC-based e-commerce application using the Repository pattern, what is the primary purpose of a Repository class?Multiple choiceEasy
- When analyzing an execution plan with EXPLAIN, which keyword indicates that an index is being used in a query?Multiple choiceHard
- How do PreparedStatements improve performance in database operations?Multiple choiceMedium
- What are the consequences of not closing a ResultSet in JDBC?Multiple choiceHard
- In a manual ORM, what happens if a ResultSet column is missing when mapping to a Java object?Multiple choiceMedium
- Why do teams use indexes in a database in production code?Multiple choiceEasy
- Which SQL clause is used to combine rows from two or more tables based on a related column?Multiple choiceEasy
- Why is it important to use setAutoCommit(false) in JDBC when managing transactions?Multiple choiceMedium
- How can you determine the number of rows in a ResultSet?Multiple choiceMedium
- What might be a consequence of not closing a PreparedStatement in a database-heavy e-commerce application?Multiple choiceHard
- Consider the following code snippet. What is a potential drawback of this JDBC transaction management approach?Multiple choiceHard
- Why do teams use PreparedStatements over Statements in JDBC in production code?Multiple choiceMedium
- Which JDBC method should you call to ensure all changes in a transaction are discarded?Multiple choiceEasy
- How would you explain a common way to iterate through a ResultSet in a Java interview?Multiple choiceEasy
- When using JDBC batch processing, which approach can help improve performance for inserts on a database with high write concurrency?Multiple choiceHard
- When using transactions in JDBC, what is the consequence of setting auto-commit to false and not explicitly calling commit()?Multiple choiceHard
- In JDBC, what is a potential consequence of leaving auto-commit mode enabled during a bulk insert operation?Multiple choiceMedium
- Which of the following sequences correctly represents handling a transaction in JDBC?Multiple choiceMedium
- Why is it useful to calling rollback() in a JDBC transaction?Multiple choiceEasy
- When using JDBC batch processing, which of the following methods is used to execute batched SQL statements?Multiple choiceMedium
- Consider the following code snippet. What will happen if one of the statements in the batch fails?Multiple choiceMedium
- Why do teams use PreparedStatements over Statements in JDBC in production code?Multiple choiceMedium
- When analyzing a query execution plan, which of the following indicates an inefficient use of indexes?Multiple choiceHard
- How can you ensure that a JDBC transaction properly handles concurrent updates to prevent lost updates?Multiple choiceHard
- Which setting should be adjusted to ensure batch statements are only committed once all are successfully executed?Multiple choiceEasy
- Why does the ResultSet in JDBC matter in practice?Multiple choiceEasy
- Which JDBC method is used to bind a String parameter to a PreparedStatement?Multiple choiceMedium
- Why does using a RIGHT JOIN between two tables, 'suppliers' and 'products', on the result set change runtime behavior?Multiple choiceMedium
- Who should usually own the transaction for a checkout that saves the order, inserts items, and updates stock?Multiple choiceMedium
- Which method is used to bind an integer parameter to a PreparedStatement?Multiple choiceMedium
- Why might using rs.getString() for all column types in a ResultSet be problematic?Multiple choiceHard
- When working with a ResultSet, what is the correct way to handle SQLException?Multiple choiceEasy
- How would you explain a key benefit of using PreparedStatements for executing complex joins in a large e-commerce database in an interview?Multiple choiceHard
- You are using JDBC batch processing to insert a list of products into the database. What is a common issue you might face if you do not properly manage the…Multiple choiceMedium
- When combining tables using a JOIN, which JDBC method allows you to safely insert parameter values into your SQL query?Multiple choiceEasy
- Which code correctly handle a SQLException when closing a ResultSet?Multiple choiceMedium