JDBC/JDBC Mcq Set 1 Sample Test,Sample questions

Question:
 Are ResultSets updateable?

1.Yes, but only if we call the method openCursor() on the ResultSet and if the driver and database support this option.

2.Yes, but only if we indicate a concurrency strategy when executing the statement, and if the driver and database support this option.

3.Yes, but only if the ResultSet is an object of class UpdateableResultSet and if the driver and database support this option.

4.No, ResultSets are never updateable. We must explicitly execute a DML statement to change the data in the underlying database.

Posted Date:-2022-01-18 07:01:22


Question:
 How constructor can be used for a servlet?

1.Initialization

2.Constructor function

3. Initialization and Constructor function

4.Setup() method

Posted Date:-2022-01-18 07:09:37


Question:
 Identify the DSN in the following statement:
DriverManager.getConnection("jdbc:odbc:oradsn", "scott", "tiger")  

1.jdbc

2.odbc

3.scott

4.oradsn

Posted Date:-2022-01-18 06:58:23


Question:
 Identify the isolation level that prevents the dirty in the JDBC Connection class?

1.TRANSACTION_READABLE_READ

2.TRANSACTION_READ_COMMITTED

3.TRANSACTION_READ_UNCOMMITTED

4.TRANSACTION_NONE

Posted Date:-2022-01-18 06:53:10


Question:
 Which of the following code is used to get an attribute in a HTTP Session object in servlets?

1. session.getAttribute(String name)

2.session.alterAttribute(String name)

3.session.updateAttribute(String name)

4.session.setAttribute(String name)

Posted Date:-2022-01-18 07:10:45


Question:
 Which of the following contains both date and time?

1. java.io.date

2. java.sql.date

3. java.util.date

4. java.util.dateTime

Posted Date:-2022-01-18 07:05:36


Question:
 Which of the following is not a JDBC connection isolation levels?

1.TRANSACTION_NONE

2.TRANSACTION_READ_COMMITTED

3.TRANSACTION_REPEATABLE_READ

4.TRANSACTION_NONREPEATABLE_READ

Posted Date:-2022-01-18 07:09:04


Question:
 Which of the following is used to limit the number of rows returned?

1.setMaxRows(int i)

2.setMinRows(int i)

3. getMaxrows(int i)

4.getMinRows(int i)

Posted Date:-2022-01-18 07:07:53


Question:
 Which of the following is used to rollback a JDBC transaction?

1.rollback()

2.rollforward()

3.deleteTransaction()

4.RemoveTransaction()

Posted Date:-2022-01-18 07:08:39


Question:
 Which statement is correct if we want to connect the Oracle database using the thin driver provided by Oracle Corp.?

1.getConnection("jdbc::thin@localhost:1521:oracle", "scott", "tiger");

2.getConnection("jdbc:thin@localhost:1521:oracle", "scott", "tiger");

3.getConnection("jdbc::thin@localhost:1522:oracle", "scott", "tiger");

4.getConnection("jdbc::oracle@localhost:1521:thin", "scott", "tiger");

Posted Date:-2022-01-18 06:58:46


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

1.JDBC tracing

2.Exception handling

3.Both a and b

4.Only b

Posted Date:-2022-01-18 06:54:40


Question:
Can servlet class declare constructor with ServletConfig object as an argument?

1.True

2.False

3.all of the above

4.none of the above

Posted Date:-2022-01-18 07:09:56


Question:
DatabaseMetaData interface is used to get?????..?

1.Comprehensive information about the database as a whole.

2.Comprehensive information about the table as a whole.

3.Comprehensive information about the column as a whole.

4.Both b and c

Posted Date:-2022-01-18 07:00:38


Question:
How many stages are used by Java programmers while using JDBC in their programs?

1.3

2.2

3.5

4.6

Posted Date:-2022-01-18 06:56:57


Question:
How many statement objects can be created using a Connection?

1.2

2.1

3.3

4.Multiple

Posted Date:-2022-01-18 07:02:05


Question:
How many transaction isolation levels provide the JDBC through the Connection interface?

1.3

2.4

3.7

4.2

Posted Date:-2022-01-18 06:50:28


Question:
How many ways to register a driver?

1.2

2.3

3.4

4.5

Posted Date:-2022-01-18 06:57:51


Question:
JDBC API supports____________ and __________ architecture model for accessing the database.

1.Two-tier

2.Three-tier

3.Both a and b

4.Only b

Posted Date:-2022-01-18 07:02:27


Question:
JDBC-ODBC driver is also known as?

1.Type 4

2.Type 3

3.Type 1

4.Type 2

Posted Date:-2022-01-18 06:55:21


Question:
Parameterized queries can be executed by?

1.ParameterizedStatement

2.PreparedStatement

3.CallableStatement and Parameterized Statement

4.All kinds of Statements

Posted Date:-2022-01-18 06:52:19


Question:
Select the packages in which JDBC classes are defined?

1.jdbc and javax.jdbc

2.rdb and javax.rdb

3.jdbc and java.jdbc.sql

4.sql and javax.sql

Posted Date:-2022-01-18 06:48:42


Question:
Stored procedure can be called by using the ????..?

1.CallableStatement

2.Statement

3.CalledStatement

4.PreparedStatement

Posted Date:-2022-01-18 06:53:54


Question:
Thin driver is also known as?

1.Type 3 Driver

2.Type-2 Driver

3.Type-4 Driver

4.Type-1 Driver

Posted Date:-2022-01-18 06:49:16


Question:
What are the major components of the JDBC?

1.DriverManager, Driver, Connection, Statement, and ResultSet

2.DriverManager, Driver, Connection, and Statement

3.DriverManager, Statement, and ResultSet

4.DriverManager, Connection, Statement, and ResultSet

Posted Date:-2022-01-18 06:46:38


Question:
What are the types of ResultSet in JDBC?

1.Forward ResultSet

2.Scrollable ResultSet

3.Only a

4.Both a and b

Posted Date:-2022-01-18 06:59:23


Question:
What does setAutoCommit(false) do?

1.It will not commit transactions automatically after each query.

2.It explicitly commits the transaction.

3.It never commits the transactions.

4.It does not commit transaction automatically after each query.

Posted Date:-2022-01-18 06:53:35


Question:
What is blob in the following statement?

create table profilepic(photo blob);  

1.Variable

2.Object

3.Data type

4.Keyword

Posted Date:-2022-01-18 06:59:46


Question:
What is JDBC Savepoint?

1.An intermediate or checkpoint in a transaction

2.A point where we can store queries

3.A point where the JDBC application starts execution

4.A memory where we can store transaction

Posted Date:-2022-01-18 06:56:37


Question:
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.

1.i, ii, iii, v, iv, vii, viii, vi

2.i, iii, ii, v, iv, vii, vi, viii

3.ii, i, iii, iv, viii, vii, v, vi

4.i, iii, ii, iv, v, vi, vii, viii

Posted Date:-2022-01-18 06:49:44


Question:
What is the difference between servlets and applets?
i. Servlets execute on Server; Applets execute on browser
ii. Servlets have no GUI; Applet has GUI
iii. Servlets creates static web pages; Applets creates dynamic web pages
iv. Servlets can handle only a single request; Applet can handle multiple requests

1. i, ii, iii are correct

2.i, ii are correct

3.i, iii are correct

4. i, ii, iii, iv are correct

Posted Date:-2022-01-18 07:10:22


Question:
What should be the correct order to close the database resource?What should be the correct order to close the database resource?

1.Connection, Statements, and then ResultSet

2.ResultSet, Connection, and then Statements

3.Statements, ResultSet, and then Connection

4.ResultSet, Statements, and then Connection

Posted Date:-2022-01-18 06:54:19


Question:
Which data type is used to store files in the database table?

1.BLOB

2.CLOB

3.File

4.Both a and b

Posted Date:-2022-01-18 07:00:08


Question:
Which JDBC driver can be used in servlet and applet both?

1.Type 3

2.Type 4

3.Type 3 and Type 2

4.Type 3 and Type 4

Posted Date:-2022-01-18 06:55:00


Question:
Which method is used to get three-letter abbreviation for locale’s country in servlets?

1.Request.getISO3Country()

2.Locale.getISO3Country()

3. Response.getISO3Country()

4. Local.retrieveISO3Country()

Posted Date:-2022-01-18 07:11:08


Question:
Which methods are required to load a database driver in JDBC?

1.getConnection()

2.registerDriver()

3.forName()

4.Both b and c

Posted Date:-2022-01-18 06:51:58


Question:
Which of the following code retrieves the body of the request as binary data?

1.DataInputStream data = new InputStream()

2.DataInputStream data = response.getInputStream()

3.DataInputStream data = request.getInputStream()

4.DataInputStream data = request.fetchInputStream()

Posted Date:-2022-01-18 07:11:43


Question:
Which of the following driver converts the JDBC calls into database-specific calls?

1.JDBC-ODBC Bridge Driver (Type 1)

2.Native API-partly Java Driver (Type 2)

3.Net Protocol-pure Java Driver (Type 3)

4.Native Protocol-pure Java Driver (Type 4)

Posted Date:-2022-01-18 07:01:00


Question:
Which of the following driver is the fastest one?

1.JDBC-ODBC Bridge Driver

2.Native API Partly Java Driver

3.Network Protocol Driver

4.JDBC Net Pure Java Driver

Posted Date:-2022-01-18 06:55:41


Question:
Which of the following interface provides the commit() and rollback() methods?

1.Statement Interface

2.ResultSet Interface

3.Connection Interface

4.RowSet Interface

Posted Date:-2022-01-18 07:01:47


Question:
Which of the following is advantage of using JDBC connection pool?

1.Slow performance

2. Using more memory

3.Using less memory

4.Better performance

Posted Date:-2022-01-18 07:06:01


Question:
Which of the following is advantage of using PreparedStatement in Java?

1. Slow performance

2.Encourages SQL injection

3.Prevents SQL injection

4.More memory usage

Posted Date:-2022-01-18 07:06:23


Question:
Which of the following is method of JDBC batch process?

1.setBatch()

2. deleteBatch()

3. removeBatch()

4.addBatch()

Posted Date:-2022-01-18 07:08:15


Question:
Which of the following is not a type of ResultSet object?

1.TYPE_FORWARD_ONLY

2.CONCUR_WRITE_ONLY

3.TYPE_SCROLL_INSENSITIVE

4.TYPE_SCROLL_SENSITIVE

Posted Date:-2022-01-18 06:56:07


Question:
Which of the following is not a valid statement in JDBC?

1.Statement

2.PreparedStatement

3.QueryStatement

4.CallableStatement

Posted Date:-2022-01-18 06:52:48


Question:
Which of the following is the correct to register a JdbcOdbcDriver?

1.jdbc.odbc.JdbcOdbcDriver obj = new sun.jdbc.odbc.JdbcOdbcDriver();

2.odbc.JdbcOdbcDriver obj = new sun.odbc.JdbcOdbcDriver();

3.jdbc.JdbcOdbcDriver obj = new sun.jdbc.JdbcOdbcDriver();

4.jdbc.odbc.JdbcOdbc obj = new sun.jdbc.odbc.JdbcOdbc();

Posted Date:-2022-01-18 06:57:25


Question:
Which of the following is used to call stored procedure?

1.Statement

2.PreparedStatement

3.CallableStatment

4.CalledStatement

Posted Date:-2022-01-18 07:07:23


Question:
Which of the following method is static and synchronized in JDBC API?

1.getConnection()

2.prepareCall()

3.executeUpdate()

4.executeQuery()

Posted Date:-2022-01-18 06:51:37


Question:
Which of the following method is used to perform DML statements in JDBC?

1.executeResult()

2.executeQuery()

3.executeUpdate()

4.execute()

Posted Date:-2022-01-18 06:50:06


Question:
Which one of the following contains date information?

1. java.sql.TimeStamp

2.java.sql.Time

3.java.io.Time

4. java.io.TimeStamp

Posted Date:-2022-01-18 07:06:48


Question:
Which statement(s) is/ are true about transactions?

i. A transaction is a set of one or more SQL statements that make up a logical unit of work.

ii. A transaction ends with either a commit or a rollback, depending on whether there are any problems with data consistency or data concurrency.

iii. A lock is a mechanism that allows two transactions from manipulating the same data at the same time.

iv. To avoid conflicts during a transaction, a DBMS uses locks, mechanisms for blocking access by others to the data that is being accessed by the transaction.

1.Only i and ii

2.Only i and iii

3.Only i, ii, and iv

4.All the above

Posted Date:-2022-01-18 07:02:54


More MCQS

  1. JDBC Mcq Set 1
  2. JDBC Mcq Set 2
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!