Home Subjects Java Programming

Java Programming

Java OOP, collections, multithreading

476 Q 10 Topics Take Test
Advertisement
Difficulty: All Easy Medium Hard 151–160 of 476
Topics in Java Programming
Q.151 Medium JDBC
Which JDBC method executes UPDATE, INSERT, or DELETE statements?
A executeQuery()
B execute()
C executeUpdate()
D executeBatch()
Correct Answer:  C. executeUpdate()
EXPLANATION

executeUpdate() executes DML statements and returns the number of rows affected.

Take Test
Q.152 Medium JDBC
What is the purpose of Connection.commit() in JDBC?
A Close the connection
B Save all changes made in the current transaction
C Rollback transactions
D Create a new statement
Correct Answer:  B. Save all changes made in the current transaction
EXPLANATION

commit() saves all changes made during the current transaction permanently to the database.

Take Test
Q.153 Medium JDBC
In JDBC, what is the purpose of CallableStatement?
A To execute simple SELECT queries
B To execute stored procedures and functions
C To batch multiple SQL statements
D To manage transaction isolation levels
Correct Answer:  B. To execute stored procedures and functions
EXPLANATION

CallableStatement is used to call stored procedures and stored functions in the database.

Take Test
Q.154 Medium JDBC
What is Connection pooling in JDBC and why is it used?
A A method to execute multiple SQL statements in parallel
B Reusing database connections to improve performance and reduce overhead
C A feature to automatically backup database connections
D A mechanism to encrypt database connections
Correct Answer:  B. Reusing database connections to improve performance and reduce overhead
EXPLANATION

Connection pooling maintains a pool of reusable connections, reducing the cost of creating new connections repeatedly.

Take Test
Q.155 Medium JDBC
Which JDBC constant specifies read-only access for a ResultSet?
A ResultSet.CONCUR_READ_ONLY
B ResultSet.TYPE_READ_ONLY
C ResultSet.MODE_READ
D ResultSet.ACCESS_READ_ONLY
Correct Answer:  A. ResultSet.CONCUR_READ_ONLY
EXPLANATION

CONCUR_READ_ONLY is the concurrency constant that specifies a read-only ResultSet.

Take Test
Q.156 Medium JDBC
In JDBC, what is the purpose of the ResultSetMetaData interface?
A To execute SQL queries
B To retrieve information about the structure of a ResultSet
C To manage database connections
D To handle transaction management
Correct Answer:  B. To retrieve information about the structure of a ResultSet
EXPLANATION

ResultSetMetaData provides information about columns, data types, and column properties of a ResultSet.

Take Test
Q.157 Medium JDBC
What happens when Connection.setAutoCommit(false) is called in JDBC?
A Auto-commit is enabled immediately
B Manual transaction control is enabled; changes require explicit commit
C All pending transactions are rolled back
D The connection is closed automatically
Correct Answer:  B. Manual transaction control is enabled; changes require explicit commit
EXPLANATION

Setting autoCommit to false enables manual transaction management where commit() must be explicitly called.

Take Test
Q.158 Medium JDBC
Which JDBC method is used to set an input parameter in a PreparedStatement?
A setParameter()
B setInt(), setString(), etc.
C bindParameter()
D addParameter()
Correct Answer:  B. setInt(), setString(), etc.
EXPLANATION

PreparedStatement uses type-specific setter methods like setInt(), setString(), setDate() to bind parameters.

Take Test
Q.159 Medium JDBC
What is the difference between ResultSet.TYPE_SCROLL_INSENSITIVE and ResultSet.TYPE_SCROLL_SENSITIVE?
A Insensitive is faster; Sensitive allows concurrent updates visibility
B Insensitive allows backward navigation; Sensitive does not
C Sensitive is read-only; Insensitive allows modifications
D They are identical and can be used interchangeably
Correct Answer:  A. Insensitive is faster; Sensitive allows concurrent updates visibility
EXPLANATION

TYPE_SCROLL_INSENSITIVE doesn't reflect concurrent database changes, while TYPE_SCROLL_SENSITIVE may reflect such changes.

Take Test
Q.160 Medium JDBC
In a JDBC batch operation, what does executeBatch() return?
A A ResultSet object
B An array of integers representing update counts
C A single integer value
D A boolean value
Correct Answer:  B. An array of integers representing update counts
EXPLANATION

executeBatch() returns an int array where each element represents the number of rows affected by each statement in the batch.

Take Test
IGET
iget AI
Online · Ask anything about exams
Hi! 👋 I'm your iget AI assistant.

Ask me anything about exam prep, MCQ solutions, study tips, or strategies! 🎯
UPSC strategy SSC CGL syllabus Improve aptitude NEET Biology tips