iGET

Java Programming - MCQ Practice Questions

Practice free Java Programming multiple-choice questions with detailed answers and explanations. Perfect for competitive exam preparation.

958 questions | 100% Free

Q.1Hard

Consider code: String query = "SELECT * FROM users WHERE id=" + userId; stmt.executeQuery(query); What security issue exists?

Q.2Hard

How would you implement batch processing in JDBC for multiple INSERT operations?

Q.3Hard

What is the difference between execute(), executeQuery(), and executeUpdate()?

Q.4Hard

Which JDBC feature allows you to call stored procedures?

Q.5Hard

In JDBC, what does the ResultSet.TYPE_SCROLL_INSENSITIVE constant represent?

Q.6Hard

What is the difference between update() and updateRow() methods in ResultSet?

Q.7Hard

A developer wants to prevent SQL injection attacks while executing dynamic queries. Which approach is most secure?

Q.8Hard

What is the default transaction isolation level in JDBC when autocommit is disabled?

Q.9Hard

Which method is used to check if a CallableStatement has a return value from a stored procedure?

Q.10Hard

A batch update operation fails partially. How can you identify which statements failed in the batch?

Q.11Hard

In JDBC, what is the purpose of using a SavePoint in a transaction?

Q.12Hard

A developer creates a JDBC connection but forgets to close it. What might be the consequence?

Q.13Hard

Consider a scenario where a developer retrieves a ResultSet and then closes the Statement object. What happens to the ResultSet?

Q.14Hard

What is the optimal approach to handle JDBC resources to prevent memory leaks in a production application?

Q.15Hard

In a multi-threaded JDBC application, why should each thread have its own Connection object?

Q.16Hard

Consider a scenario: A developer uses Statement with user input directly in SQL queries. What is the primary risk?

Q.17Hard

In a JDBC application, when using transactions with setAutoCommit(false), what happens to intermediate savepoints if rollback() is called?

Q.18Hard

Which JDBC feature should be used for executing multiple SQL statements in a batch for optimal performance?

Q.19Hard

In JDBC, what is the significance of setting FetchSize on a Statement when dealing with large ResultSets?

Q.20Hard

When using JDBC with Spring Framework in 2024-25, which approach is recommended for resource management?