Web Design and Development MCQs with Answers
Practice important Web Design and Development MCQs with answers and explanations.
Multiple Choice Questions
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
View Answer
C
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");
View Answer
A
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)
View Answer
B
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)
View Answer
B
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
View Answer
B
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
View Answer
C
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)
View Answer
B
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
View Answer
C
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
View Answer
B
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
View Answer
B