NPTEL Programming in Java Week 11 Assignment Answers 2024
1. How do you establish a connection to a database using JDBC?
a. By creating an instance of the Connection interface
b. By using the DriverManager.getConnection() method
c. By implementing the Connection interface
d. By extending the Connection class
Answer :- For Asnwers Click Here
2. Which method executes a simple query and returns a single Result Set object?
a. executeQuery()
b. executeUpdate()
c. execute()
d. run()
Answer :- For Asnwers Click Here
3. What is the correct order to close database resources?
a. Connection then Statement then ResultSet
b. ResultSet then Statement then Connection
c. Statement then Connection then ResultSet
d. Statement then ResultSet then Connection
Answer :-
4. Which of the following ensures that the correct driver is used to access each data source.
a. java.sql.Connection
b. java.sql.DriverManager
c. java.sql.Statement
d. java.sql.Driver
Answer :-
5. What is the purpose of the ResultSet interface in JDBC?
a. To store the result of a query
b. To execute SQL queries
c. To manage database connections
d. To update data in the database
Answer :-
6. The following is a statement in Java using JDBC.
Which of the following statement is FALSE?
a. 3306 is the default MySQL port.
b. Database name is ‘nptel’
c. The database server is hosted on IP 127.0.0.1
d. Password for ‘java’ user is ‘joy’
Answer :- For Asnwers Click Here
7. Which resources have their close() method called when this code runs?
a. No close() methods are called
b. Only Statement
c. Only Statement and Connection
d. Only Statement and ResultSet
Answer :-
8. Which of the following is used to call stored procedure?
a. Statement
b. PreparedStatement
c. CallableStatment
d. CalledStatement
Answer :-
9. The executeUpdate method can be used with
a. Statements(Select and Update both)
b. Select statement.
c. Update/delete/insert operations in the database.
d. Only insert operation.
Answer :-
10. What does setAutoCommit(false) do?
a. commits transaction after each query
b. explicitly commits transaction
c. does not commit transaction automatically after each query
d. never commits transaction
Answer :- For Asnwers Click Here