Font size
WorksheetsSec BCD 21-7-2023 Quiz-2
Total questions: 149
Worksheet time: 1hrs 15mins
Which driver is efficient and always preferable for using JDBC applications?
Type-4
Type-3
Type-2
Type-1
Which JDBC driver Type(s) is(are) the JDBC-ODBC bridge?
Type 1
Type 2
Type 3
Type 4
Which packages contain the JDBC classes?
java.jdbc and javax.jdbc
java.jdbc and java.jdbc.sql
java.sql and javax.sql
java.rdb and javax.rdb
Which type of Statement can execute parameterized queries?
PreparedStatement
ParameterizedStatement
ParameterizedStatement and CallableStatement
All kinds of Statements (i.e. which implement a sub interface of Statement)
How can you retrieve information from a ResultSet?
By invoking the method get(…, String type) on the ResultSet, where type is the database type
By invoking the method get(…, Type type) on the ResultSet, where Type is an object which represents a database type
By invoking the method getValue(…), and cast the result to the desired Java type.
By invoking the special getter methods on the ResultSet: getString(…), getInt (…), getDouble(…),…
How can you execute a stored procedure in the database?
Call method execute() on a CallableStatement object
Call method executeProcedure() on a Statement object
Call method execute() on a StoredProcedure object
Call method run() on a ProcedureCommand object
Which method is used to perform DML statements in JDBC?
execute()
executeQuery()
executeUpdate()
executeResult()
Which of the following is correct about PreparedStatement?
Prepared statements offer better performance, as they are pre-compiled.
Prepared statements reuse the same execution plan for different arguments rather than creating a new execution plan every time.
Prepared statements use bind arguments, which are sent to the database engine.
All of the above.
In order to transfer data between a database and an application written in the Java programming language, the JDBC API provides which of these methods?
Methods on the ResultSet class for retrieving SQL SELECT results as Java types.
Methods on the PreparedStatement class for sending Java types as SQL statement parameters.
Methods on the CallableStatement class for retrieving SQL OUT parameters as Java types.
All mentioned above
The performance of the application will be faster if you use PreparedStatement interface because query is compiled only once.
True
False
Which method is used to establish the connection with the specified url in a Driver Manager class?
public static void registerDriver(Driver driver)
public static void deregisterDriver(Driver driver)
public static Connection getConnection(String url)
public static Connection getConnection(String url,String userName,String password)
Which driver Network connection is indirect that a JDBC client makes to a middleware process that acts as a bridge to the DBMS server?
JDBC-Net
JDBC-ODBC bridge
Native API as basis
Native protocol as basis
Which is used to call the stored procedures and functions?
CallableStatement Interface
PreparedStatement Interface
All the above
None of the above
What is used to execute parameterized query?
Statement interface
PreparedStatement interface
ResultSet interface
None of the above
ODBC stands for?
Open database connection
Open database concept
Open database communications
None of the above
Which models do the JDBC API support for the database access?
Two-tier models
Three-tier models
Both A & B
None of the above
Which of the following is used to rollback a JDBC transaction?
rollback()
rollforward()
deleteTransaction()
RemoveTransaction()
The method on the result set that tests whether or not there remains at least one unfetched tuple in the result set, is said to be
Fetch method
Current method
Next method
Access method
Which method is used to perform DML statements in JDBC?
execute()
executeQuery()
executeUpdate()
executeResult()
Which of the following describes the correct sequence of the steps involved in making a connection with a database.
1. Loading the driver
2. Process the results.
3. Making the connection with the database.
4. Executing the SQL statements.
1 ,3,4,2
1,2,3,4
1,4,3,2
1,2,4,3
Which of the following tasks are associated with JDBC library?
Making a connection to a database.
Creating SQL or MySQL statements.
Executing SQL or MySQL queries in the database.
All of these
Expand JDBC
(a)
_____________ interface handles the communications with the database server
DriverManager
Driver
Statement
None of these
___________ interface with all methods for contacting a database.
ResultSet
Statement
Connection
Driver
The third step involved in JDBC application is ____________
Execute Query
Establish Connection
importing packages
Register the Driver
In Type 2 Driver, JDBC API calls are converted into native _____________ API calls, which are unique to the database
C/C++
Java
JavaScript
Visual Programming
Type 4 Driver is also called as (a)
_____________ driver talks with server-side middleware which then talks to the database
Type 1
Type 2
Type 3
Type 4
(a) should be imported to use SQL statements
The most common approach to register a driver is to use Java's (a) method.
To open a connection, DriverManager. (a) () is to be used.
Which method returns an integer as its result?
execute()
executeUpdate()
executeQuery()
extract()
Which interface will NOT accept input parameters
Statement
PreparedStatement
CallableStatement
PrepareStatement
All parameters in JDBC are represented by the ? symbol, which is known as the (a) .
in a ResultSet object, the ___________ methods to retrieve the value of a given column.
POST()
GET()
setXXX()
getXXX()
We bind values to _________ parameters with the setXXX methods
OUT
IN
INPUT
OUTPUT
The corresponding SQL type for the boolean JAVA type is_____
BOOLEAN
BIT
BOOL
BYTE
(a) method returns the total number of columns in the ResultSet object.
_____________interface is used to execute stored procedures.
Statement
PreparedStatement
CallableStatement
execute
(a) method is used to create an object of the class ResultSetMetaData.
What is the return type of executeUpdate() method?
byte
short
int
long
What is the return type of executeQuery() method?
int
ResultSet
array
none of the above
what is the package name of "Class"?
java.util
java.sql
java.lang
java.io
What is true about DriverManager class?
It is class from java.lang package
It is a class from java.sql package
It is a interface from java.sql package
It is a class from java.lang package
What is JDBC?
JDBC is a java based protocol.
JDBC is a standard Java API for database-independent connectivity between the Java programming language and a wide range of databases.
JDBC is a specification to tell how to connect to a database.
Joint Driver for Basic Connection
Which of the following encapsulates an SQL statement which is passed to the database to be parsed, compiled, planned and executed?
DriverManager
JDBC driver
Connection
Statement
Which of the following is not a valid type of statement in JDBC?
Statement
PreparedStatement
CallableStatement
QueryStatement
Which of the following is correct about PreparedStatement?
Used when you plan to use the SQL statements many times.
The PreparedStatement interface accepts input parameters at runtime.
Both of the above.
None of the above.
what is true about getConnection() method?
It is a static method from DriverManager class
It is a non static method from DriverManager class
It is a static method from DriverManager interface
It is a non static method from DriverManager interface
Which package contains JDBC classes and interfaces?
java.lang
java.io
java.sql
java.jdbc
JDBC Stands for _________
Java Database Connectivity
Java Driver Connectivity
Java Developer Connectivity
None of the above
Select the packages in which JDBC classes and interfaces are defined?
Which of the following is the correct method to make a connection with database?
Driver.getConnection()
Driver.connection()
DriverManager.getConnection()
DriverManager.connection()
Which of the following method will load the driver?
Class.forName()
Class.loadDriver()
Class.load()
Class.driverName()
Which of the following method is used to execute insert query in JDBC?
executeUpdate()
executeQuery()
execute()
executeInsert()
Which of the following method is used execute select query in JDBC?
executeUpdate()
executeQuery()
execute()
executeSelect()
Which of the following method will create prepared statement object in JDBC?
con.prepareStatement()
con.statement()
con.createStatement()
con.createPStatement()
What is the return type of ResultSet next() method?
boolean
int
String
long
Which of the following is the class from JDBC API?
DriverManager
ResultSet
PreparedStatement
Connection
Which of the following is the correct order to write a JBDC program?
Load the driver, Making Connection, Statement Creation and Executing the Query
Load the driver, Statement Creation, Making Connection, and Executing the Query
Statement Creation, Load the driver, Making Connection, and Executing the Query
Making Connection, Statement Creation, Load the driver and Executing the Query
Predict the output:
Compiletime Error at line 6
Compiletime Error at line 7 : Unhandled IOException
accepts string and displays on the screen
None of the above
Predict the output:
Compile time error
Run time error
Java
Unix
Java
Unix
Oracle
C++
Perl
Predict the output:
Hello from Parent
Hello from Child
Compilation Error
None of the above
Predict the output:
Compile Time Error : Array size is negative
Runtime Exception : Array size is negative
0
-0
Predict the output
Kucu Kucu
I speak
compile time error
runtime exception
Predict the output:
Java
PJP
Compile time error
Runtime Exception : IndexOutOfBoundsException
None of the above
Predict the output:
10
11
10
10
11
11
11
10
What is the return type of setter method?
void
It depends on the instance variable's data type whose value we are trying to retrieve.
Which of the below options is correct to load the Oracle JDBC driver?
Class.forName("oracle.jdbc.driver.OracleDBDriver");
Class.forName("Oracle.Jdbc.Driver.OracleDriver");
Class.forName("jdbc.oracle.driver.OracleDriver");
Class.forName("oracle.jdbc.driver.OracleDriver");
Which of the below queries is correct to display the Employee details such as empno, ename, sal from emp table whose empno contains 77 in it?
select empno,ename,sal from emp where empno is 77;
select empno,ename,sal from emp where empno like '_77%';
select empno,ename,sal from emp where empno like '%77%';
select empno,ename,sal from emp where empno like '_77_';
What JDBC stands for ?
Java Database Connectivity
Java Driver for Basic Connection
Joint Database Connectivity
Joint Driver for Basic Connection
How many Types of JDBC-Drivers available ?
5
4
3
6
Which JDBC Driver Type is the JDBC-ODBC bridge ?
Type-4
Type-3
Type-2
Type-1
Which driver is called as thin-driver in JDBC ?
Type-2
Type-4
Type-3
Type-1
Which driver is callled Native-API driver ?
Type-4
Type-2
Type-3
Type-1
What are the correct sequence of steps to connect any database using JDBC ?
import packages,load or register the driver class,establish connection,create the statement,execute queries,close the connection
establish connection,import packages,load or register the driver class,execute queries,create the statement,close the connection
create the statement,import the packages,establish connection,import packages,load or register the driver class,execute queries,close the connection
establish connection,create the statement,import the packages,import packages,load or register the driver class,execute queries,close the connection
Which of the following method is needed for loading a database driver in JDBC ?
registerDriver() method
Class.forName() method
Both 1 and 2
None of the above
Which packages contain the JDBC classes?
java.jdbc and javax.jdbc
java.jdbc and java.jdbc.sql
java.sql and javax.sql
java.rdb and javax.rdb
------------- method is used to execute any SQL Statement with a SELECT clause, that return the result of the query as a
execute()
executeQuery()
executeUpdate()
executeBatch()
Which method is used to execute INSERT,DELETE,UPDATE and other SQL DDL commands such as CREATE or DROP Table?
execute()
executeQuery()
executeUpdate()
executeBatch()
What is return type of executeUpdate() method ?
int
String
Date
ResultSet
What are the different types of Statements available in JDBC?
Statement
PreparedStatement
CallableStatement
All of the above
Which type of Statement can execute parameterized queries ?
ParameterizedStatement
PreparedStatement
CallableStatement
All kinds of Statements (i.e. which implement a sub interface of Statement)
Which method returns ResultSet as output?
execute()
executeQuery()
executeUpdate()
executeBatch()
Which java.sql class or interface contains methods that enable you to find out the number of columns this is returned in a ResultSet and the name or label for a given column?
Statement
CallableStatement
ResultSetMetaData
MetaData
What are the Interfaces available in JDBC?
Connection interface
PreparedStatement interface
ResultSet interface
ResultSet interface
What are the methods in Statement Interface?
public ResultSet executeQuery(String sql): is used to execute SELECT query. It returns the object of ResultSet.
public int executeUpdate(String sql): is used to execute specified query, it may be create, drop, insert, update, delete etc.
public boolean execute(String sql): is used to execute queries that may return multiple results.
public int[] executeBatch(): is used to execute batch of commands.
This method is for retrieving a String Value(SQL type VARCHAR) and assigning to String Object.
getVarchar()
getString()
getObject()
getInt()
How can you retrieve information from a ResultSet?
By invoking the method get(…, String type) on the ResultSet, where type is the database type
By invoking the method get(…, Type type) on the ResultSet, where Type is an object which represents a database type
By invoking the method getValue(…), and cast the result to the desired Java type.
By invoking the special getter methods on the ResultSet: getString(…), getInt (…), getDouble(…),…
Which type of Statement can execute parameterized queries?
PreparedStatement
ParameterizedStatement
ParameterizedStatement and CallableStatement
All kinds of Statements (i.e. which implement a sub interface of Statement)
Which packages contain the JDBC classes?
java.jdbc and javax.jdbc
java.jdbc and java.jdbc.sql
java.sql and javax.sql
java.rdb and javax.rdb
How can you execute a stored procedure in the database?
Call method execute() on a CallableStatement object
Call method executeProcedure() on a Statement object
Call method execute() on a StoredProcedure object
Call method run() on a ProcedureCommand object
Which method is used to perform DML statements in JDBC?
execute()
executeQuery()
executeUpdate()
executeResult()
Which of the following is correct about PreparedStatement?
Prepared statements offer better performance, as they are pre-compiled.
Prepared statements reuse the same execution plan for different arguments rather than creating a new execution plan every time.
Prepared statements use bind arguments, which are sent to the database engine.
All of the above.
In order to transfer data between a database and an application written in the Java programming language, the JDBC API provides which of these methods?
Methods on the ResultSet class for retrieving SQL SELECT results as Java types.
Methods on the PreparedStatement class for sending Java types as SQL statement parameters.
Methods on the CallableStatement class for retrieving SQL OUT parameters as Java types.
All mentioned above
The performance of the application will be faster if you use PreparedStatement interface because query is compiled only once.
True
False
Which method is used to establish the connection with the specified url in a Driver Manager class?
public static void registerDriver(Driver driver)
public static void deregisterDriver(Driver driver)
public static Connection getConnection(String url)
public static Connection getConnection(String url,String userName,String password)
Which is used to call the stored procedures and functions?
CallableStatement Interface
PreparedStatement Interface
All the above
None of the above
Which of the following is correct about Statement class of JDBC?
A - Statement encapsulates an SQL statement which is passed to the database to be parsed and compiled.
B - Statement encapsulates an SQL statement which is passed to the database to be planned and executed.
C - Both of the above.
D - none of the above.
Which of the following type of JDBC driver, uses database native protocol?
A - JDBC-ODBC Bridge plus ODBC driver
B - Native-API, partly Java driver
C - JDBC-Net, pure Java driver
D - Native-protocol, pure Java driver
Which of the following is not a valid type of statement in JDBC?
A - Statement
B - PreparedStatement
C - CallableStatement
D - QueryStatement
Which of the following is correct about PreparedStatement?
A - PreparedStatement allows mapping different requests with same prepared statement but different arguments to execute the same execution plan.
B - Prepared statements are more secure because they use bind variables, which can prevent SQL injection attack.
C - Both of the above.
D - None of the above.
What are the major components of the JDBC?
DriverManager, Driver, Connection, Statement, and ResultSet
DriverManager, Driver, Connection, and Statement
DriverManager, Statement, and ResultSet
DriverManager, Connection, Statement, and ResultSet
Select the packages in which JDBC classes are defined?
jdbc and javax.jdbc
rdb and javax.rdb
jdbc and java.jdbc.sql
sql and javax.sql
Thin driver is also known as?
Type 3 Driver
Type-2 Driver
Type-4 Driver
Type-1 Driver
Which of the following method is used to perform DML statements in JDBC?
executeResult()
executeQuery()
executeUpdate()
execute()
How many transaction isolation levels provide the JDBC through the Connection interface?
3
4
7
2
Which of the following method is static and synchronized in JDBC API?
getConnection()
prepareCall()
executeUpdate()
executeQuery()
JDBC stands for
(a)
Which is the first step for connecting Java and database
Establish Connection
Create Statement object
Load and Register JDBC Driver
Execute SQL statements
JDBC Driver is same to all database softwares.
True
False
Which of the following is Type 1 JDBC Driver
Middleware
Native
Bridge
Pure
Which of the following manages all the Drivers found in JDBC environment?
Connection
ResutSet
Statement
DriverManager
Which of the following is used to store the result of SQL query?
Statement
ResultSet
Connection
DriverManager
Class.forName() is used to
establish connection
execute SQL statements
load and register Driver
set the database
Which function is used to execute SQL SELECT statement?
executeQuery()
executeUpdate()
executeSelect()
executeAll()
Fill in the blanks
Class.forName( (a) );
Fill in the blanks:
Connection con=DriverManager.getConnection( " (a) /databasename" , "username", "password" );
Fill in the blanks.
Statement st = con. (a) ;
st. (a) ("CREATE TABLE stud1(roll int, name varchar(15))");
PreparedStatement represents a precompiled SQL statement
True
False
Which class is used to represent error or warning during access from database or during connectivity?
SQLError
SQL command
Statement object
SQLException
JDBC API helps to provide universal data access from the Java programming language
True
False
(a) should be imported to use SQL statements
To open a connection, DriverManager. (a) () is to be used.
Which method returns an integer as its result?
execute()
executeUpdate()
executeQuery()
extract()
We bind values to _________ parameters with the setXXX methods
OUT
IN
INPUT
OUTPUT
The corresponding SQL type for the boolean JAVA type is_____
BOOLEAN
BIT
BOOL
BYTE
Which of the following is correct about JDBC?
The JDBC API provides the abstraction and the JDBC drivers provide the implementation.
The JDBC API provides the abstraction and the JDBC drivers provide the implementation.
Both of the above.
Both of the above.
What are the major components of the JDBC?
DriverManager, Driver, Connection, Statement, and ResultSet
DriverManager, Driver, Connection, and Statement
DriverManager, Statement, and ResultSet
DriverManager, Connection, Statement, and ResultSet
Select the packages in which JDBC classes are defined?
jdbc and javax.jdbc
rdb and javax.rdb
jdbc and java.jdbc.sql
sql and javax.sql
Which of the following method is used to perform DML statements in JDBC?
executeResult()
executeQuery()
executeUpdate()
execute()
Which methods are required to load a database driver in JDBC?
getConnection()
registerDriver()
forName()
Both b and c
Which of the following is not a valid statement in JDBC?
Statement
PreparedStatement
QueryStatement
CallableStatement
A good way to debug JDBC-related problems is to enable?
JDBC tracing
Exception handling
Both a and b
Only b
Which data type is used to store files in the database table?
BLOB
CLOB
File
Both a and b
New drivers can be plugged-in to the JDBC API without changing the client code.
TRUE
FALSE
Which JDBC type represents a "single precision" floating point number that supports seven digits of mantissa?
REAL
DOUBLE
FLOAT
INTEGER
Abbreviate the term UDA?
Unified Data Access
Universal Data Access
Universal Digital Access
Uniform Data Access
Which methods returns a stream that simply provides the raw bytes from the database without any conversion?
getCharacterStream
getBinaryStream
getAsciiStream
getUnicodeStream
The ACID properties does not describes the transaction management well.
TRUE
FALSE
Which interfaces provide methods for batch processing in JDBC?
java.sql.Statement
java.sql.PreparedStatement
All the above
None of the above
Which JDBC type represents a 64-bit signed integer value between -9223372036854775808 and 9223372036854775807?
SMALLINT
BIGINT
TINYINT
INTEGER
Which method is used for an SQL statement that is executed frequently?
prepareStatement
prepareCall
createStatement
None of the above
Which statement is wrong about PRIMARY KEY constraint in SQL?
The PRIMARY KEY uniquely identifies each record in a SQL database table
Primary key can be made based on multiple columns
Primary key must be made of any single columns
Primary keys must contain UNIQUE values.
In existing table, ALTER TABLE statement is used to
Add columns or constraints
Delete columns or constraints
All the above
Logical operators used in SQL are
AND, OR , NOT
&&, ||, !
&,|,!
None of the above
Which clause is used to combine rows from two or more tables based on a related column between them.
SQL MATCH
SQL JOIN
SQL PATTERN
NONE
Correct SQL query syntax to update a record from a table is
UPDATE table_name
SET column1 = value1, column2 = value2, … WHERE condition;
UPDATE table_name SET COLUMN column1 = value1, column2 = value2, … WHERE condition;
UPDATE table_name UPDATE column1 = value1, column2 = value2, … WHERE condition;
UPDATE table_name column1 = value1, column2 = value2, … WHERE condition;
None
