Skip to main content

Web Design and Development MCQs with Answers

Practice important Web Design and Development MCQs with answers and explanations.

Chapter: 14
Q221:
What is the correct URL format to connect to a Microsoft Access database using JDBC-ODBC driver?
A. jdbc:oracle:thin:@localhost:1521
B. jdbc:mysql://localhost:3306/mydatabase
C. jdbc:odbc
D. jdbc:postgresql://localhost:5432/mydb
Correct Answer: C
Chapter: 14
Q222:
How do you load a JDBC driver for Oracle database?
A. Class.forName("oracle.jdbc.driver.OracleDriver");
B. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
C. Class.forName("com.mysql.cj.jdbc.Driver");
D. Class.forName("org.postgresql.Driver");
Correct Answer: A
Chapter: 14
Q223:
Which method of Statement class is used to execute a SQL SELECT query?
A. executeUpdate(sql)
B. executeQuery(sql)
C. execute(sql)
D. executeBatch(sql)
Correct Answer: B
Chapter: 14
Q224:
How do you retrieve a column value by index from a ResultSet object?
A. rs.getInt(columnIndex)
B. rs.getString(columnIndex)
C. rs.getValue(columnIndex)
D. rs.get(columnIndex)
Correct Answer: B
Chapter: 14
Q225:
What does the executeUpdate method return when an SQL query is executed?
A. A ResultSet object
B. An integer representing the number of rows affected
C. A boolean indicating success or failure
D. The SQL query string
Correct Answer: B
Chapter: 15
Q226:
How should you handle exceptions when working with JDBC operations?
A. Ignoring them
B. Printing them to the console only
C. Wrapping them in a try-catch block
D. Ignoring and continuing
Correct Answer: C
Chapter: 15
Q227:
Which method of DriverManager class is used to establish a connection to the database?
A. getDriver()
B. getConnection(url)
C. getConnection()
D. getDatabaseConnection(url)
Correct Answer: B
Chapter: 15
Q228:
What is the main advantage of using an inner class for event handling in Java Swing?
A. Easier to debug
B. Simplifies handling multiple events
C. Reduces code size and avoids inheritance issues
D. Enhances performance
Correct Answer: C
Chapter: 15
Q229:
What does the executeUpdate() method return when executing an SQL DML statement?
A. ResultSet object
B. Number of rows affected
C. Boolean indicating success
D. The SQL query string
Correct Answer: B
Chapter: 15
Q230:
Which type of SQL statements can executeUpdate() handle?
A. SELECT and JOIN statements
B. INSERT, UPDATE, and DELETE statements
C. Only SELECT statements
D. Only DDL statements
Correct Answer: B
Chapter: 15
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
Correct Answer: B
Chapter: 15
Q232:
_____________ is the method to get an object from a file.
A. readObject()
B. readStream()
C. read()
D. None of the above
Correct Answer: A
Chapter: 15
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
Correct Answer: C
Chapter: 15
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
Correct Answer: B
Chapter: 15
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
Correct Answer: C
Chapter: 15
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")
Correct Answer: C
Chapter: 15
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
Correct Answer: B
Chapter: 16
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
Correct Answer: B
Chapter: 16
Q239:
Which JDBC object is used for executing stored procedures?
A. Statement
B. PreparedStatement
C. CallableStatement
D. Connection
Correct Answer: C
Chapter: 16
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
Correct Answer: B

Test Your Knowledge

Take a timed quiz on Web Design and Development

🚀 Start Quiz Now