JDBC MCQs

JDBC MCQs

Our experts have gathered these JDBC MCQs through research, and we hope that you will be able to see how much knowledge base you have for the subject of JDBC by answering these 100+ multiple-choice questions.
Get started now by scrolling down!

1: JDBC is an API for the _________ programming language.

A.   PHP

B.   ABAP

C.   Java

D.   C#

2: _____ will create a RowSet object.

A.   All of the above

B.   Using the reference implementation constructor that takes a Connection object

C.   Using an instance of RowSetFactory, which is created from the class RowSetProvider

D.   Using the reference implementation default constructor

3: _______ is not a method of a ResultSet cursor.

A.   end

B.   beforeFirst

C.   next

D.   previous

4: ______ is NOT a subclass of SQLException

A.   BatchUpdateException

B.   SQLTransientException

C.   SQLFailureException

D.   SQLNonTransientException

5: While accessing databses such as Oracle, Sybase or IBM, the preferred driver type is:

A.   Type 4: 100% Pure Java

B.   Type 3: JDBC-Net pure Java

C.   Type 1: JDBC-ODBC Driver Bridge

D.   Type 2: JDBC-Native API

6: _______ is not a valid ResultSet type.

A.   TYPE_SCROLL_INSENSITIVE

B.   TYPE_SCROLL_SENSITIVE

C.   TYPE_BACKWARD_ONLY

D.   TYPE_FORWARD_ONLY

7: A ________ is a subclass of SQLException.

A.   Exception

B.   SQLError

C.   SQLWarning

D.   SQLMethod

8: public void updateString(int columnIndex, String s) throws SQLException

A.   Changes the String in the specified row specified by its index to the value of s

B.   Changes the String in the specified column specified by its name to the value of s

C.   Changes the String in the specified row specified by its name to the value of s

D.   Changes the String in the specified column specified by its index to the value of s

9: The _______ method adds SQL commands to the list associated with a Statement object.

A.   addSQL

B.   updateList

C.   select

D.   addBatch

10: In order to access Database stored procedures, the best JDBC interface is:

A.   CallableStatement

B.   ProcedureStatement

C.   Statememt

D.   PreparedStatement

11: Which of the following is not an overloaded DriverManager.getConnection () method?

A.   getConnection(String url, Properties prop)

B.   getConnection(String url, String user, String password)

C.   getConnections()

D.   getConnection(String url)

12: A ______ is not contained in an SQLException.

A.   effect

B.   error code

C.   description of the error

D.   SQLState code

13: To jump back to a specific point in the program, create a:

A.   Savepoint

B.   Marker

C.   Reference

D.   Anchor

14: boolean execute (String SQL) returns:

A.   the number of columns affected by the executon of the SQL statement

B.   the number of rows affected by the executon of the SQL statement

C.   boolean value of true if a resultset object can be retrieved

D.   Returns a Resultset object

15: A ________ is used to mark intermediate points inside a transaction in order to get a more fine-grained control.

A.   connection point

B.   pointer

C.   savepoint

D.   stored procedure

16: The executeUpdate method from Statement returns:

A.   an integer representing the number of rows affected by the SQL statement

B.   true if the first object that the query returns is a ResultSet object

C.   one ResultSet object

D.   multiple ResultSet objects

17: All JDBC Rowset objects are derived from which interface?

A.   PreparedStatement

B.   ResultSet

C.   CallableStatement

D.   Statement

18: ________ is an object used for precompiling SQL statements that may contain input parameters.

A.   Callable Statement

B.   Stored Procedure

C.   Query

D.   Prepared Statement

19: ______ is NOT a valid parameter mode for a stored procedure.

A.   OUT

B.   CONSTANT

C.   INOUT

D.   IN

20: True or False? The RowSet object holds data in a tabular form that is more flexible and easier to use than the ResultSet object.

A.   False

B.   True

21: JDBC API uses which drivers to connect to the database?

A.   jdbc

B.   .Net

C.   odbc

D.   Microsoft

22: To close existing database connections, you should call

A.   exit() method

B.   escape() method

C.   close() method

D.   shutdown() method

23: True or False? JDBC is an API to access relational databases, spreadsheets, and flat files.

A.   True

B.   False

24: True or False? A transaction is closed when close() is called on the Connection object.

A.   True

B.   False

25: True or False? The default mode when a connection is created is auto-commit mode.

A.   True

B.   False

26: In order to accept input parameters at runtime, use the following JDBC interface:

A.   ParameterStatement

B.   PreparedStatement

C.   Statement

D.   RuntimeStatement

27: {fn length('Friday')} will return

A.   12

B.   6

C.   Friday

D.   null

28: Which of the following in not required by the getConnection() method to create a connecton object?

A.   Password

B.   Database url

C.   Username

D.   Website url

29: In the command jdbc:derby:testdb;create=true, testdb stands for

A.   Server name

B.   Port name

C.   Client name

D.   Database name

30: At the end of the JDBC program, it is explicity required to close al the connections to the database? True or False

A.   False

B.   True

31: When a Driver Class is loaded, it creates an instance of itself and registers it with:

A.   SocketManager

B.   ClassManager

C.   ConnectionManager

D.   DriverManager

32: True or False? If executing a Statement object many times, a PreparedStement object will reduce execution time.

A.   True

B.   False

33: True or False? SQLWarning objects are a subclass of SQLException.

A.   False

B.   True

34: _______ extends the RowSet interface.

A.   WebRowSet

B.   All of the above

C.   JoinRowSet

D.   CachedRowSet

35: If the column you are interested in viewing contains an int, which of the following methods of Resultset can be used?

A.   getString()

B.   getInt()

C.   getNumber()

D.   getDate()

36: The Class.forname() method is used to:

A.   Call another method

B.   get name for the Class

C.   register the jdbc driver

D.   Rename class

37: If the ResultSet type is TYPE_FORWARD_ONLY, it implies:

A.   the cursor can scroll backwards and forwards

B.   the cursor can move forward in the result set

C.   the cursor can scroll forwards and backwards

D.   the cursor can move backards in the result set

38: A ______ object lets you access the data returned by an SQL statement.

A.   Result

B.   ResultSet

C.   SQLCursor

D.   ReturnSet

39: Which of the following is NOT needed to set up a JDBC Environment:

A.   Database

B.   .Net

C.   Java

D.   Database drivers

40: The SQLXML interface provides the _____ method to access its internal content.

A.   getBinaryStream

B.   getString

C.   getCharacterStream

D.   All of the above

41: In order to commit changes to the database, use:

A.   confirm

B.   save

C.   apply

D.   commit

42: If a database operation fails, JDBC raises an:

A.   NullException

B.   SQLException

C.   SecurityException

D.   AccessException

43: JDBC stands for _______.

A.   Java Data Behavior Control

B.   Java Database Connectivity

C.   Java Direct Binary Connection

D.   Java Database Control

44: What kind of database is the command jdbc:mysql:://localhost:3306/ is connecting to?

A.   JavaDB

B.   IBM DB2

C.   MySQL

D.   Microsoft Access

45: True or False? JDBC will work with many different database management systems.

A.   False

B.   True

46: You must register your JDBC driver in your program before using it? True or False

A.   False

B.   True

47: Which package contains the JDBC classes?

A.   javax.swing

B.   java.nio

C.   java.net

D.   java.sql

48: In the syntax {ts 'yyyy-mm-dd hh:mm:ss'}, ts stands for

A.   time

B.   date

C.   seconds

D.   timestamp

49: The most common exception you'll deal with JDBC:

A.   ArithmeticException

B.   NullPointerException

C.   FileNotFoundException

D.   SQLException

50: In order to undo the previous transaction, use

A.   rollback

B.   escape

C.   undo

D.   back