Tutorial 5

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Tutorial 5

1.What does JDBC stand for? –


a) Java Database Control b) Java Database Connectivity c) Java Data Binding Connector d) Java Database Console

2.Which package in Java contains the JDBC classes?


a) java.sql b) java.jdbc c) java.db d) java.connection

3. In JDBC, which interface is responsible for making a connection to the database?


a) Driver b) Connection c) Statement d) ResultSet

4.Which of the following is used to execute SQL queries in JDBC?


a) DriverManager b) Connection c) ResultSet d) PreparedStatement

5.What is the purpose of the `ResultSet` interface in JDBC?


a) To connect to the database b) To execute SQL queries c) To store query results d) To create a database table

5.Which of the following is not a type of JDBC driver?


a) Type 1 b) Type 2 c) Type 4 d) Type 6

6. Which driver type is known as the “Thin driver” in JDBC?


a) Type 1 b) Type 2 c) Type 3 d) Type 4

7. What is the purpose of the `PreparedStatement` interface in JDBC?


a) To connect to the database b) To store query results c) To precompile SQL statements d) To execute DDL commands

8. Which method is used to establish a connection to the database in JDBC?


a) createConnection() b) openConnection() c) getConnection() d) establishConnection()

9. Which of the following is not a valid SQL data type in JDBC?


a) VARCHAR b) INT c) DOUBLE d) BOOLEAN

10. What is the purpose of the `Statement` interface in JDBC?


a) To connect to the database b) To execute SQL queries c) To precompile SQL statements d) To store query results

11. In JDBC, which exception is thrown when there is a problem with the SQL syntax?
a) SQLException b) SQLSyntaxException c) SQLQueryException d) SyntaxError

12. Which method is used to execute a query in JDBC and retrieve the results in a `ResultSet`?
a) executeQuery() b) executeUpdate() c) execute() d) executeBatch()

13. What is the purpose of the `Connection` interface in JDBC?


a) To execute SQL queries b) To store query results c) To manage the connection to the database d) To compile SQL

14. In JDBC, what is the role of the `DriverManager` class?


a) To establish a connection to the database b) To execute SQL queries
c) To manage the result set d) To manage the connection pool database

15. Which of the following is used to create a JDBC connection to a database?


A. DriverManager.getConnection() B. Connection.getConnection()
C. Statement.getConnection() D. PreparedStatement.getConnection()

16. Which of the following is used to execute an SQL query in JDBC?


A. Statement.executeQuery() B. Connection.executeQuery()
C. PreparedStatement.executeQuery() D. ResultSet.executeQuery()

17. Which of the following is used to close a JDBC connection?


A. Connection.close() B. Statement.close() C. PreparedStatement.close() D. ResultSet.close()
18. Which of the following is used to handle exceptions in JDBC?
A. try-catch block B. throws clause C. finally block D. All of the above

19. Which of the following is a benefit of using a PreparedStatement in JDBC?


A. It prevents SQL injection. B. It improves performance. C. Both A and B. D. None of the above.

20. Which of the following is a JDBC connection isolation level?


A. READ UNCOMMITTED B. READ COMMITTED C. REPEATABLE READ
D. SERIALIZABLE E. All of the above

24. Which of the following is a JDBC savepoint?


A. A point in a transaction where you can rollback to if an error occurs.
B. A way to commit a subset of the changes made in a transaction.
C. Both A and B.
D. None of the above.

25. Which of the following is a JDBC batch update?


A) A way to execute multiple SQL statements at once. B) A way to improve the performance of bulk database operations.
C) Both A and B. D). None of the above.

26. The package contains classes that help in connecting to a database, sending SQL statements to the database and process
the query request.
(a)connection.sql (b)b.sql (c)pkg.sql (d)java.sql

27. Which of the following is not a type of JDBC driver?


(a)100% pure Java Driver (b)JDBC–net pure Java Driver
(c)JDBC–Native API driver (d)JDBC–Native pure Java Driver

28.In JDBC imports all Java classes that are concern with Database connectivity.
(a) javax.sql (b)java.mysql (c)java.sql (d)com.sql

29.Database programming using Java throws which of the following exception?


(a)SQLException (b)ClassNotFoundException (c)None of these (d) Both of these

30.In the below statement, which type of query can be used with executeUpdate() method. statement.executeUpdate(query here)
(a)Insert, Update, Delete (b)Insert, Select, Delete (c)Only Select (d) Any Query

31. What is purpose of next( ) method?


(a) to retain the next element in a series. (b) to retain next table.
(c) to retain next record in a series. (d) None of the above

32.What are the major component of the jdbc?


a) DriverManager, DriverConnection, Statement and Resultset b) DriverManager, DriverConnection, and Resultset
c) DriverManager, DriverConnection, Statement d) DriverManager, Connection, Statement and Resultset

You might also like