Web Design and Development MCQs with Answers
Practice important Web Design and Development MCQs with answers and explanations.
Multiple Choice Questions
Q231: What is the purpose of the setMaxRows(int) method in JDBC?
- A: It sets the maximum number of columns in a ResultSet
- B: It determines the maximum number of rows in a ResultSet
- C: It limits the execution time of a query
- D: It sets the maximum size of the ResultSet
View Answer
B
Q232: _____________ is the method to get an object from a file.
- A: readObject()
- B: readStream()
- C: read()
- D: None of the above
View Answer
A
Q233: How can you handle SQL exceptions in JDBC?
- A: Ignoring them
- B: Printing them to the console
- C: Using try-catch blocks
- D: Wrapping them in a try-finally block
View Answer
C
Q234: What is the main difference between Statement and PreparedStatement in JDBC?
- A: Statement is used for precompiled SQL, while PreparedStatement is for dynamic SQL
- B: PreparedStatement is used for precompiled SQL, while Statement is for dynamic SQL
- C: Statement can execute stored procedures
- D: PreparedStatement cannot execute queries
View Answer
B
Q235: How do you set a parameter in a PreparedStatement?
- A: Using the setParameter method
- B: Using the setValue method
- C: Using the setXXX methods (e.g., setString, setInt)
- D: Using the addParameter method
View Answer
C
Q236: Which class method is used to load the JDBC driver for Microsoft Access?
- A: Class.forName("oracle.jdbc.driver.OracleDriver")
- B: Class.forName("com.mysql.cj.jdbc.Driver")
- C: Class.forName("sun.jdbc.odbc.JdbcOdbcDriver")
- D: Class.forName("org.postgresql.Driver")
View Answer
C
Q237: What is the purpose of the getQueryTimeout() method?
- A: To set the maximum number of rows in a ResultSet
- B: To get the current query timeout limit
- C: To set the maximum number of columns in a ResultSet
- D: To set the maximum size of the ResultSet
View Answer
B
Q238: How should you use the executeUpdate() method in a PreparedStatement?
- A: Use it to execute SQL SELECT queries
- B: Use it to execute SQL INSERT, UPDATE, or DELETE queries
- C: Use it for DDL statements like CREATE TABLE
- D: Use it to create or drop tables
View Answer
B
Q239: Which JDBC object is used for executing stored procedures?
- A: Statement
- B: PreparedStatement
- C: CallableStatement
- D: Connection
View Answer
C
Q240: What happens if you do not explicitly commit the changes made by executeUpdate()?
- A: The changes will be rolled back automatically
- B: The changes are not saved permanently
- C: The database will save the changes automatically
- D: The program will throw an exception
View Answer
B