Java Programming — JDBC
Java OOP, collections, multithreading
100 Questions 10 Topics Take Test
Advertisement
Showing 91–100 of 100 questions in JDBC
Q.91 Medium JDBC
What is Connection pooling in JDBC?
A Storing multiple database connections in a pool for reuse
B Combining multiple queries into one
C Creating backup connections
D Automatic connection switching
Correct Answer:  A. Storing multiple database connections in a pool for reuse
EXPLANATION

Connection pooling maintains a pool of reusable database connections to improve performance and reduce overhead of creating new connections repeatedly.

Take Test
Q.92 Medium JDBC
Which method must be called to move cursor to the next row in ResultSet?
A next()
B moveNext()
C advance()
D fetch()
Correct Answer:  A. next()
EXPLANATION

The next() method moves the ResultSet cursor to the next row and returns true if a row exists, false if no more rows. It's essential for iterating through results.

Take Test
Q.93 Medium JDBC
What is the primary advantage of using PreparedStatement over Statement?
A Faster execution and SQL injection prevention
B Larger result set size
C Better memory management
D Automatic type conversion
Correct Answer:  A. Faster execution and SQL injection prevention
EXPLANATION

PreparedStatement offers faster execution due to precompilation and prevents SQL injection through parameterized queries using placeholders (?).

Take Test
Q.94 Medium JDBC
Which interface is used to execute precompiled SQL statements in JDBC?
A Statement
B PreparedStatement
C CallableStatement
D BatchStatement
Correct Answer:  B. PreparedStatement
EXPLANATION

PreparedStatement is used for precompiled SQL statements with parameters. It provides better performance and prevents SQL injection compared to Statement.

Take Test
Q.95 Medium JDBC
What does the executeUpdate() method return in JDBC?
A A ResultSet object
B Number of rows affected
C A boolean value
D Query execution time
Correct Answer:  B. Number of rows affected
EXPLANATION

executeUpdate() returns an integer representing the number of rows affected by INSERT, UPDATE, or DELETE operations. executeQuery() returns ResultSet.

Take Test
Advertisement
Q.96 Easy JDBC
Which method is used to retrieve a String value from a ResultSet object?
A getInt()
B getString()
C fetchString()
D readString()
Correct Answer:  B. getString()
EXPLANATION

getString() method retrieves String values from ResultSet. getInt() gets integer values, and fetchString/readString are not valid JDBC methods.

Take Test
Q.97 Easy JDBC
What exception is thrown when a database connection cannot be established?
A SQLException
B ClassNotFoundException
C IOExceptionn
D NullPointerException
Correct Answer:  A. SQLException
EXPLANATION

SQLException is thrown for database-related errors including connection failures. ClassNotFoundException occurs when JDBC driver class is not found.

Take Test
Q.98 Easy JDBC
Which JDBC driver type is platform-independent and does not require native code?
A Type 1 Driver
B Type 2 Driver
C Type 3 Driver
D Type 4 Driver
Correct Answer:  D. Type 4 Driver
EXPLANATION

Type 4 (Thin) drivers are pure Java drivers, platform-independent, and don't require native code. They communicate directly with database using Java sockets.

Take Test
Q.99 Easy JDBC
What is the correct order of JDBC operations?
A Load Driver → Create Connection → Create Statement → Execute Query → Close Resources
B Create Connection → Load Driver → Execute Query → Create Statement → Close Resources
C Load Driver → Execute Query → Create Connection → Create Statement → Close Resources
D Create Statement → Load Driver → Create Connection → Execute Query → Close Resources
Correct Answer:  A. Load Driver → Create Connection → Create Statement → Execute Query → Close Resources
EXPLANATION

The correct JDBC sequence is: 1) Load the JDBC driver, 2) Create connection, 3) Create statement, 4) Execute query, 5) Process results, 6) Close resources.

Take Test
Q.100 Easy JDBC
Which interface in JDBC is used to execute SQL queries and obtain results?
A Statement
B Connection
C ResultSet
D Driver
Correct Answer:  A. Statement
EXPLANATION

Statement interface is used to execute SQL queries. Connection is used to establish database connection, ResultSet holds query results, and Driver manages database connections.

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