0% found this document useful (0 votes)
63 views10 pages

5 Answer

Uploaded by

danepratik4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views10 pages

5 Answer

Uploaded by

danepratik4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Sanjivani Rural Education Society’s

SANJIVANI K. B. P. POLYTECHNIC
Department of Computer Technology
/ 64
KOPARGAON – 423601, DIST: AHMEDNAGAR

2023-2024
Sub Name : Advanced Java Programming (AJP-22517) Course Code : CM-5-I
Name : Date: / /2023
Roll No : Set: I
Practice Test: [Unit V – Interacting with Database]

1. In following statements is an object of _____________ interface of JDBC API. System.prinln(re.getString(3)).


(a) RowSet (b) Statement (c) Connection (d) ResultSet

(d) ResultSet

2. Which is main component of JDBC API?


(a) DriverManager (b) Driver (c) Connection (d) All of these

(d) All of these

3. How many steps are used to connect any java application with the database using JDBC ?
(a) 5 (b) 4 (c) 3 (d) 6

(b) 4

4. ODBC minimum SQL grammer contains____


(a) Stored procedure (b) Data, Time and TimeStamp only (c) create or drop View (d) Insert, update, delete only

(d) Insert, update, delete only

5. Which class/interface is used for an SQL statement that is executed frequently?


(a) Statement (b) CallableStatement (c) PreparedStatement (d) None of the above

(c) PreparedStatement

6. What does the following code do : smt = con.createStatement( )


(a) A PreparedStatement object is created to send SQL commands to database
(b) A Statement object is created to send SQL commands to database.
(c) A CallableStatement is created to send SQL commands to database
(d) A Statement object is created to execute parameterized SQL commands.

(b) A Statement object is created to send SQL commands to database.

7. Which kind of driver converts JDBC calls into calls on the Client API for Oracle, Sybase, Informix, IBM DB2, or other DBMS
(a) JDBC ODBC bridge + ODBC Driver (b) Native API partly ñ Java Driver
(c) JDBC ñ Net pure Java Driver (d) Native Protocol Pure Java Driver

(b) Native API partly ñ Java Driver


8. Which method executes an SQL statement that may return multiple results?
(a) executeUpdate( ) (b) executeQuery( ) (c) execute( ) (d) noExecute( )

(c) execute( )

9. Identify correct syntax of executeQuery( ) of Statement interface.


(a) public static ResultSet executeQuery( ) (b) public ResultSet executeQuery(String q)
(c) public void executeQuery(String q) (d) public int executeQuery(String q)

(b) public ResultSet executeQuery(String q)

10. Native API converts __ into the __ used by DBMS.


(a) JDBC API, Network Protocol (b) JDBC API, Native API calls(c) JDB
(c) API, use calls (d) JDBC API, ODBC API calls

(b) JDBC API, Native API calls

11. Which of the following function is used to find the column count of the particular ResultSet.
(a) getMetadata( ) (b) metadata( ) (c) getColumnCount( ) (d) getCount( )

(a) getMetadata( )

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

(c) java.sql

13. 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) db.sql (c) pkg.sql (d) java.sql

(d) java.sql

14. 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

(d) JDBC – Native pure Java Driver

15. Database programming using Java throws which of the following exception?
(a) SQLException (b) ClassNotFoundException (c) None of these (d) Both of these (d) Both of these
16. 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

(a) Insert, Update, Delete

17. 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

(c) to retain next record in a series.

18. Native – protocol pure Java Driver converts _______ into the _________ directly.
(a) JDBC calls, network protocol (b) ODBC class, network protocol
(c) ODBC class, user calls (d) JDBC calls, user calls

(a) JDBC calls, network protocol

19. Choose the correct syntax for getConnection( ) method.


(a) public static Connection getConnection(String url, String password) throws SQLException
(b) public static Connection getConnection(String name, String password) throws SQLException
(c) public static Connection getConnection(String url, String name, String password) throws SQLException
(d) (d) public static Connection getConnection(String url, String name) throws SQLException

(c) public static Connection getConnection(String url, String name, String password) throws SQLException

20. SQL stands for __________.


(a) Structured Query Language (b) Sequential Query Language
(c) Structured Question Language (d) Sequential Question Language

(a) Structured Query Language

21. _____________ is a table of data which represents a data from table.


(a) MetaData (b) ResultSetMetaData (c) ResultSet (d) Statement

(c) ResultSet

22. Public class DriverManager extends ____________.


(a) Object (b) String (c) Connection (d) Statement

(a) Object
23. Which of the following method is supported by Statement interface?
(a) public boolean execute(String query) (b) public ResultSet executeQuery(String query)
(c) public int executeUpdate(String query) (d) All of above

(d) All of the above

24. The JDBC‐ODBC bridge supports how many concurrent open statements per connection ?
(a) 1 (b) 0 (c) Does not support conection (d) None of these

(a) 1

25. Select the correct method to create CallableStatement.


(a) CallableStatement prepareCall(String sql)
(b) CallableStatement prepareCall(String sql, int resultset type, int resultset_concurrency)
(c) CallableStatement prepareCall(String sql, int resultset_type, int resultset_concurrency, int resultset_holdability) (d) All of the
above

(d) All of the above

26. Microsoft Access data in _______ file format.


(a) .DAT (b) .MDB (c) .MSSQL (d) .OBJ

(b) .MDB

27. Which of the following method is used for send SQL statements?
(a) Statement (b) CallableStatement (c) PreparedStatement (d) Both B & C

(d) Both B & C

28. DELETE statement of an SQL is executed by ________.


(a) execute( ) (b) executeQuery( ) (c) executeUpdate( ) (d) executeDelete()

(c) executeUpdate()

29. The interface to the database is handle by _____.


(a) ODBC (b) JDBC (c) JDBC & ODBC (d) APIs

(b) JDBC

30. DatabaseMetadata are retrieved through ___________.


(a) getDatabaseMetadata( ) (b) getMetaData( ) (c) getDBMetaData( ) (d) getDatabaseMeta( )

(b) getMetaData()
31. Which method is used to retrieve the ResultSet created?
(a) executeQuery( ) (b) getResultSet( ) (c) getResultSetResult( ) (d) getResult( )

(a) executeQuery()

32. Which of the following is used generally for reading the content of the database?
(a) DabaseData (b) DabaseData (c) ResultSet (d) DatabaseResult.

(c) ResultSet

33. The syntax to create a table named “Course”, should begin with __________.
(a) create new table course (b) create table course (c) table course create (d) new table course

(b) create table course

34. Which of the following contains both date and time?


a) java.io.date b) java.sql.date c) java.util.date d) java.util.dateTime

(c) java.util.Date

35. Which of the following is advantage of using JDBC connection pool?


a) Slow performance b) Using more memory c) Using less memory d) Better performance

(d) Better performance

36. Which of the following is advantage of using PreparedStatement in Java?


a) Slow performance b) Encourages SQL injection c) Prevents SQL injection d) More memory usage

(c) Prevents SQL injection

37. Which one of the following contains date information?


a) java.sql.TimeStamp b) java.sql.Time c) java.io.Time d) java.io.TimeStamp

(a) java.sql.Timestamp

38. 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

c) does not commit transaction automatically

39. Which of the following is used to call stored procedure?


a) Statement b) PreparedStatement c) CallableStatment d) CalledStatement
(c) CallableStatement
40. Which of the following is used to limit the number of rows returned?
a) setMaxRows(int i) b) setMinRows(int I) c) getMaxrows(int i) d) getMinRows(int i)

a) setMaxRows(int i)

41. Which of the following is method of JDBC batch process?


a) setBatch() b) deleteBatch() c) removeBatch() d) addBatch()

d) addBatch()

42. Which of the following is used to rollback a JDBC transaction?


a) rollback() b) rollforward() c) deleteTransaction() d) RemoveTransaction()

a) rollback()

43. Which of the following is not a JDBC connection isolation levels?


a) TRANSACTION_NONE b) TRANSACTION_READ_COMMITTED
c) TRANSACTION_REPEATABLE_READ d) TRANSACTION_NONREPEATABLE_READ

(d) TRANSACTION_NONREPEATABLE_READ

44. Choose the correct syntax for getConnection( ) method.


(a) public static Connection getConnection(String url, String password) throws SQLException
(b) public static Connection getConnection(String name, String password) throws SQLException
(c) public static Connection getConnection(String url, String name, String password) throws SQLException (d) public static
Connection getConnection(String url, String name) throws SQLException

(c) public static Connection getConnection(String url, String name, String password) throws SQLException

45. The syntax to create a table named ìCourseî, should begin with ____.
(a) create new table course (b) create table course
(c) table course create (d) new table course

(b) create table course

46. What are the major components of the JDBC?


(a) DriverManager, Driver, Connection, Statement, and ResultSet
(b) DriverManager, Driver, Connection, and Statement
(c) DriverManager, Statement, and ResultSet
(d) DriverManager, Connection, Statement, and ResultSet

(a) DriverManager, Driver, Connection, Statement, and ResultSet

47. Select the packages in which JDBC classes are defined?


a. jdbc and javax.jdbc b. rdb and javax.rdb c. jdbc and java.jdbc.sql d.sql and javax.sql
(d) sql and javax.sql

48. Thin driver is also known as?


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

(c) Type-4 Driver

49. What is the correct sequence to create a database connection?


i. Import JDBC packages. ii. Open a connection to the database. iii. Load and
register the JDBC driver. iv. Execute the statement object and return a query
resultset. v. Create a statement object to perform a query. vi. Close the resultset and statement objects. vii.
Process the resultset. viii. Close the connection.

a) i, ii, iii, v, iv, vii, viii, vi b) i, iii, ii, v, iv, vii, vi, viii c)ii, i, iii, iv, viii, vii, v, vi d)i, iii, ii, iv, v, vi, vii, viii

b) i, iii, ii, v, iv, vii, vi, viii

50. Which of the following method is used to perform DML statements in JDBC?
a) executeResult() b) executeQuery() c) executeUpdate() d) execute()

(c) executeUpdate()

51. How many transaction isolation levels provide the JDBC through the Connection interface?
a) 3 b) 4 c) 7 d) 2

(b) 4

52. Which of the following method is static and synchronized in JDBC API?
a) getConnection() b)prepareCall() c) executeUpdate() d)executeQuery()

(a) getConnection()

53. Which methods are required to load a database driver in JDBC?


a) getConnection() b) registerDriver() c) forName() d) Both b and c

(d) Both b and c

54. Parameterized queries can be executed by?


a)ParameterizedStatement b)PreparedStatement
c) CallableStatement and Parameterized Statement d)All kinds of Statements
(b) PreparedStatement

55. Which of the following is not a valid statement in JDBC?


a) statement b) PreparedStatement c) QueryStatement d)CallableStatement

(c) QueryStatement

56. What does setAutoCommit(false) do?


a) It will not commit transactions automatically after each query. b) It explicitly commits the transaction.
c) It never commits the transactions. d) It does not commit transaction automatically after each query.

(a) It will not commit transactions automatically after each query

57. A good way to debug JDBC-related problems is to enable???..?


a) JDBC tracing b) Exception handling c) Both a and b d) Only b

(c) Both a and b

58. Which statement is used to roll back a transaction in JDBC?


a) ROLLBACK b) COMMIT c) BEGIN TRANSACTION d) SET TRANSACTION

(a) ROLLBACK

59. What is the purpose of the java.sql.DriverManager class in JDBC?


a) To manage database transactions b) To create a connection to the database
c) To represent a SQL statement d) To execute stored procedures

b) To create a connection to the database

60. Which type of ResultSet allows changes made in the ResultSet to be reflected in the database?
a) ResultSet.TYPE_FORWARD_ONLY b) ResultSet.TYPE_SCROLL_INSENSITIVE
c) ResultSet.TYPE_SCROLL_SENSITIVE d) ResultSet.TYPE_UPDATABLE

(d) ResultSet.TYPE_UPDATABLE

61. . Which method is used to retrieve the SQL warning associated with a JDBC Connection?
a) getWarning() b) fetchWarning( ) c) retrieveWarning() d) obtainWarning()

(a) getWarning()

62. Which method is used to retrieve the auto-generated keys after an INSERT operation, but only for specific columns?
a) getGeneratedKeys() b) fetchGeneratedKeys() c) retrieveGeneratedKeys() d) obtainGeneratedKeys()

(a) getGeneratedKeys()
63. In JDBC, which interface provides methods to work with large binary data, such as images or files, stored in a database?
a) java.sql.Clob b) java.sql.Blob c) java.sql.BinData d) java.sql.LargeData

(b) java.sql.Blob

64. In JDBC, what is the purpose of the ResultSetMetaData interface?


a) To retrieve database metadata b) To represent a result set
c) To execute SQL queries d) To manage database connections

(a) To retrieve database metadata

You might also like