0% found this document useful (0 votes)
18 views8 pages

Chap5 Database 2

Uploaded by

patilvashra
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)
18 views8 pages

Chap5 Database 2

Uploaded by

patilvashra
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/ 8

(c) 2,1,3,4

INTERFACING WITH (b) 1,2,3,4


(d) 4,1,2,3
DATABASE ANSWER: A

1. Preparedstatement Object in JDBC is used to 7. _____ is the key to ______


execute _______ queries. (a) Serialization, persistence
(a) executable (b) Persistence, inheritance
(b) simple (c) Inheritance, object
(c) high level (d) Persistence, serialization
(d) parameterized ANSWER: A
ANSWER: D
8. A java program cannot directly communicate
2. In JDBC _______ imports all Java classes with an ODBC driver because ______
concerned with database connectivity (a) ODBC written in C language
(a) javax.sql.* (b) ODBC written in C# language
(b) java.mysql.* (c) ODBC written in C++ language
(c) java.sql.* (d) ODBC written in Basic language
(d) com.* ANSWER: A
ANSWER: C
9. ______ an open source DBMS product that
3. Which JDBC driver Type(s) can be used in runs on UNIX, Linux and Windows
either applet or servlet code? (a) MySQL
(a) Both Type 1 and Type 2 (b) JSP/SQL
(b) Both Type 1 and Type 3 (c) JDBC/SQL
(c) Both Type 3 and Type 4 (d) Sun ACCESS
(d) Type 4 only ANSWER: A
ANSWER: C
10. The ________ method executes a simple query
4. Where is metadata stored in MySQL? and returns a single Result Set object
(a) In the MySQL database metadata (a) executeUpdate()
(b) In the MySQL database metasql (b) executeQuery()
(c) In the MySQL database mysql (c) execute()
(d) None of the above is correct. (d) noexecute()
ANSWER: C ANSWER: B

5. MS-SQL stores data in a ______ file format. 11. The JDBC-ODBC Bridge driver translates the
(a) .DAT JDBC API to the ODBC API and used with
(b) .MDB ______
(c) .MSSQL (a) JDBC drivers
(d) .0BJ (b) ODBC drivers
ANSWER: A (c) Both A and B
(d) None of the above
6. Which of the following describes the correct ANSWER: B
sequence of the steps involved in making a
connection with a database. 12. The ________ object allows you to execute
1. Loading the driver parametrized queries.
2. Process the results. (a) ResultSet
3. Making the connection with the database. (b) Parametrized
4. Executing the SQL statements. (c) PreparedStatement
(a) 1,3,4,2 (d) Condition
ANSWER: C
13. The _______ method executes an SQL 19. Which was first most widely used programming
statement that may return multiple results interface for accessing relational databases. It
(a) executeUpdate() offers the ability to connect to almost all
(b) executeQuery() databases on almost all platforms?
(c) execute() (a) JDBC API
(d) noexecute() (b) ODBC API
ANSWER: C (c) Both (a) and (b)
(d) None of the above
14. The ________ method sets the query ANSWER: B
parameters of the PreparedStatement Object
(a) putString) 20. Abbreviate for the term UDA?
(b) insertString() (a) Unified Data Access
(c) setString() (b) Universal Data Access
(d) setToString() (c) Universal Digital Access
ANSWER: C (d) Uniform Data Access
ANSWER: B
15. Connection object can be initialized using the
_____ method of the Driver Manager class. 21. Microsoft has introduced UDA as an umbrella
(a) putConnection() term that covers?
(b) setConnection() (a) OLE DB
(c) Connection() (b) ADO
(d) getConnetion() (c) ODBC
ANSWER: D (d) All mentioned above
ANSWER: D
16. The parameters of the Preparedstatement
object are ______ when the user clicks on the 22. Which models does JDBC API supports for
Query button. database access?
(a) initialized (a) Two-tier models
(b) started (b) Three-tier models
(c) paused (c) Both (a) and (b)
(d) stopped (d) None of the above
ANSWER: A ANSWER: C

17. The ______ object provides you with methods 23. In which model a Java applet or application
to access data from the table. talks directly to the data source?
(a) ResultSet (a) Two-tier models
(b) Parametrized (b) Three-tier models
(c) TableStatement (c) Both (a) and (b)
(d) Condition (d) None of the above
ANSWER: A ANSWER: A

18. A JDBC technology-based driver ("JDBC driver") 24. In which of the following JDBC a server
makes it possible to do? technology are its support for?
(a) Establish a connection with a data source (a) Connection pooling
(b) Send queries and update statements to the (b) Distributed transactions
data source (c) Disconnected rowsets
(c) Process the results (d) All mentioned above
(d) All mentioned above ANSWER: D
ANSWER: D
25. In the following which JDBC product
components does the Java software
(a) the JDBC driver manager
(b) the JDBC driver test suite (c) Native API as basis
(b) the JDBC-ODBC bridge (d) Native protocol as basis
(d) All mentioned above ANSWER: A
ANSWER: D
32. A leading database connectivity vendor, worked
26. How many JDBC product components does the together to produce the
Java software provides? (a) JDBC-ODBC bridge
(a) 3 (b) JDBC Driver Test Suite
(b) 2 (c) Both (a) and (b)
(c) 4 (d) None of the above
(d) 5 ANSWER: C
ANSWER: A
33. Which list gives a quick way to determine which
27. Which class has traditionally been the backbone Connection method is appropriate for creating
of the JDBC architecture? different types of SQL statements?
(a) the JDBC driver manager (a) createStatement
(b) the JDBC driver test suite (b) PrepareStatement
(c) the JDBC-ODBC bridge (c) prepareCall
(d) all mentioned above (d) All mentioned above
ANSWER: A ANSWER: D

28. Which provides some confidence that JDBC 34. Which method is used for an SQL statement
driver will run your program? that is executed frequently?
(a) the JDBC-ODBC bridge (a) prepareStatement
(b) the JDBC driver manager (b) prepareCall
(d) the JDBC driver test suite (c) createStatement
(d) None of the above (d) None of the above
ANSWER: C ANSWER: A

29. JDBC technology-based drivers generally fit into 35. How many result sets available with the JDBC
how many categories? 2.0 core APL. The following constants, defined
(a) 4 in the ResultSet interface, are used to specify
(b) 3 these?
(c) 2 (a) 2
(d) 5 (b) 3
ANSWER: A (c) 4
(d) 5
30. Which kind of driver converts JDBC calls into ANSWER: B
calls on the client API for Oracle, Sybase,
Informix, IBM DB2, or other DBMS? 36. In which the result set generally does not show
(a) JDBC-ODBC bridge plus ODBC driver changes to the underlying database that are
(b) Native-API partly-Java driver made while it is open. The membership, order,
(c) JDBC-Net pure Java driver and column values of rows are typically fixed
(d) Native-protocol pure Java driver when the result set is created?
ANSWER: B (a) type_forward_only
(b) type_scroll_insensitive
31. In which driver Network connection is indirect (c) type_scroll_sensitive
that a JDBC client makes to a middleware (d) all mentioned above
process that acts as a bridge to the DBMS ANSWER: B
server?
(a) JDBC-Net 37. In concurrency which indicates a result set that
(b) JDBC-ODBC bridge cannot be updated programmatically?
(a) concur_updatable (c) a large variable-length binary value
(b) concur read_ only (d) Both (a) and (b)
(c) both (a) and (b) ANSWER: A
(d) None of the above
ANSWER: B 43. What is the disadvantage of Type-4 Native-
Protocol Driver?
38. Which methods returns a stream that simply (a) At client side, a separate driver is needed for
provides the raw bytes from the database each database.
without any conversion? (b) Type-4 driver is entirely written in Java
(a) getCharacterStream (c) The driver converts JDBC calls into vendor-
(b) getBinaryStream specific database protocol
(c) getASCIIStream (d) It does not support to read MySQL data
(d) getUnicodeStream ANSWER: C
ANSWER: B
44. Which method is used to perform DML
39. Which method is used for retrieving streams of statements in JDBC?
both ASCII and Unicode characters is new in the (a) execute()
JDBC 2.0 core API? (b) executeQuery()
(a) getCharacterStream (c) executeUpdate()
(b) getBinaryStream (d) executeResult()
(c) getASCIIStream ANSWER: C
(d) getUnicodeStream
ANSWER: A 45. Which driver is called as thin-driver in JDBC?
(a) Type-4 driver
40. In order to transfer data between a database (b) Type-1 driver
and an application written in the Java (c) Type-3 driver
programming language, the JDBC API provides (d) Type-2 driver
which of these methods? ANSWER: A
(a) Methods on the ResultSet class for retrieving
SQL SELECT results as Java types. 46. When the message "No Suitable Driver" occurs?
(b) Methods on the PreparedStatement class for (a) When the driver is not registered by
sending Java types as SQL statement parameters. Class.forname() method
(c) Methods on the CallableStatement class for (b) When the user name, password and the
retrieving SOL OUT parameters as Java types. database does not match
(d) All mentioned above (c) When the JDBC database URL passed is not
ANSWER: D constructed properly
(d) When the type 4 driver is used
41. In which the JDBC type represents a 64-bit ANSWER: C
signed integer value between
9223372036854775808 and 47. Are prepared statements actually compiled?
9223372036854775807? (a) Yes, they compiled
(a) smallint (b) No, they are bound by the JDBC driver
(b) bigint ANSWER: A
(c) tinyint
(d) integer 48. Which of the following methods finds the
ANSWER: B maximum number of connection that a specific
driver can obtain?
42. The JDBC types binary, varbinary, and (a) Database.getMaxConnections
longvarbinary are closely related in that (b) Connection.getMaxConnections
varbinary represents (c) DatabaseMetaData.getMaxConnections
(a) a small variable-length binary value (d) ResultSetMetaData.getMaxConnections
(b) a small fixed-length binary value ANSWER: C
49. BLOB, CLOB, ARRAY and REF type columns can 55. The JDBC-ODBC Bridge supports multiple
be updated in ________. concurrent open statements per connection?
(a) JDBC 1.0 (a) True
(b) JDBC 4.0 (b) False
(c) JDBC 2.0 ANSWER: B
(d) JDBC 3.0
ANSWER: D 56. Which of the following is false as far as type 4
driver is concern?
50. The class java.sql.Timestamp has its super class (a) Type 4 driver is "native protocol, pure java"
as driver
(a) java.sql.Time (b) Type 4 drivers are 100% Java compatible
(b) java util.Date (c) Type 4 drivers uses Socket class to connect to
(c) java.util.Time the database
(d) None of the above (d) Type 4 drivers can not be used with Netscape
ANSWER: B ANSWER: D

51. All raw data types (including binary documents 57. Which statement is static and synchronized in
or images) should be read and uploaded to the JDBC API?
database as an array of ________. (a) executeQuery()
(a) byte (b) executeupdate()
(b) int (c) getConnection()
(c) Boolean (d) prepareCall()
(d) char ANSWER: A
ANSWER: A
58. Which of the following describes the correct
52. The JDBC-ODBC bridge is ________. sequence of the steps involved in making a
(a) Three tiered connection with a database
(b) Multithreaded 1. Loading the driver
(c) Best for any platform 2. Process the results
(d) All of the above 3. Making the connection with the database
ANSWER: A 4. Executing the SQL statements
(a) 1, 3, 4, 2
53. JDBC facilitates to store the java objects by (b) 1, 2, 3, 4
using which of the methods of (c) 2, 1, 3, 4
PreparedStatement (d) 4, 1, 2, 3
1. setObject () ANSWER: A
2. setBlob()
3. setClob() 59. Which of the following statement is false as far
(a) 1, 2 as different type of statements is concern in
(b) 1, 2, 3 JDBC?
(c) 1, 3 (a) Regular Statement
(d) 2, 3 (b) Callable Statement
ANSWER: B (c) Prepared Statement
54. Which driver is efficient and always preferable (d) Interim statement
for using JDBC applications? ANSWER: D
(a) Type-4
(b) Type-1 60. Which of the following methods are needed for
(c) Type-3 loading a database driver in JDBC?
(d) Type-2 (a) registerDriver() method
ANSWER: A (b) Class.forName() method
(c) both (a) and (b)
(d) getConnection() method
ANSWER: C (b) Driver
(c) DSN
61. Which is the correct option from the following (d) CLI
for JDBC driver types? ANSWER: B
(a) 1. JDBC-ODBC bridge plus ODBC driver, also
called Type 1 65. Which JDBC driver works as an interface
2. Native-API, partly Java driver, also called between the JDBC application and the ODBC
Type 2. driver?
3. JDBC-Net, pure Java driver, also called Type (a) Native-API-Partly-Java driver
3 (b) Native Protocol Pure-Java driver
4. Native-protocol, pure Java driver, also called (c) JDBC-ODBC Bridge driver
Type 4 (d) JDBC-Net-Pure-Java driver
(b) 1. JDBC-ODBC bridge plus ODBC driver, also ANSWER: C
called Type 1
2. Native-protocol, pure Java driver, also called 66. Which JDBC driver maps the JDBC calls to the
Type 2 native method calls, which are passed to the
3. JDBC-Net, pure Java driver, also called Type local native Call Level Interface (CLI)?
3 (a) Native-API-Partly-Java driver
4. Native-API, partly Java driver, also called (b) JDBC-ODBC Bridge driver
Type 4. (c) Native Protocol Pure-Java driver
(c) 1. JDBC-Net, pure Java driver, also called Type (d) JDBC-Net-Pure-Java driver
1 ANSWER: A
2. Native-API, partly Java driver, also called
Type 2 67. Which interface enables you to establish a
3. JDBC-ODBC bridge plus ODBC driver, also connection between a Java application and a
called Type 3 database?
4. Native-protocol, pure Java driver, also called (a) Statement interface
Type 4. (b) ResultSet interface
(d) None of these (c) DriverManager interface
ANSWER: A (d) Connection interface
ANSWER: B
62. What is the purpose of next() method?
(a) next () method is used to retain next
elements in a series.
(b) next () method is used to retain next table
(c) next () method is used to retain next record in
a series
(d) None of the above
ANSWER: A

63. _________ layer signifies a Java application that


uses the JDBC API to interact with the JDBC
drivers.
(a) JDBC application layer
(b) JDBC driver layer
(c) JDBC driver manager layer
(d) JDBC API layer
ANSWER: A

64. A JDBC __________ is a software that a Java


application uses to access a database.
(a) Driver manager
DATA BASE (APPLICATION LEVEL)
1. The following step is for _______.
stmt.executeUpdate (sql);
sql = "INSERT INTO Registration " + "VALUES(103,'Sumit','Mittal,28)";
stmt.executeUpdate (sql);
(a) Insert
(b) Delete
(c) Update
(d) Display
ANSWER: A

2. What will be the output of following code?


import java.sql.*;
public class JdbcGetConnection
{
public static void main(String args [])
{
Connection con = null;
Statement st = null;
ResultSet rs = null;
try
{
Class.forName("com , mysql.jdbc.Driver");
con = DriverManager.getConnection
("jdbc:mysql://localhost:3306/koma1", "root","root");
System.out.println ("Connection is closed: "+con.isClosed());
con.close();
System.out.println("Connection is closed: "+con.isclosed());
}
catch (Exception e)
{
System.out.println(e);
}
}
}
(a) Connection is closed : false
Connection is closed : true
(b) Connection is closed : true
(c) Connection is closed true
Connection is closed true
(d) Connection is closed : false
Connection is closed : false
ANSWER: A

3. Which of the following piece of code shows how to retrieve the value Row Id for a particular Row?
(a) String selectQuery = "select rowid from Employees where id='123'";
ResultSet resultSet = statement.executeQuery("selectQuery)";
java.sql.Rowid rowId = resultSet.getRowId();
(b) String selectQuery = "select rowid from Employees where id='123'";
ResultSet resultSet = statement.executeQuery("selectQuery");
java.sql.Rowid rowId = ResultSet.getRowId();
(c) String selectQuery = "select rowid from Employees where id='123'";
ResultSet resultSet = Statement.ExecuteQuery("selectQuery");
java.sql.Rowid rowId = resultSet.getRowId();
(d) None of the above
ANSWER: A
4. To execute a stored procedure "totalStock" in a database server, which of the following code
snippet is used?
(a) Statement stmt = connection.createStatement();
stmt.execute("totalStock()");
(b) CallableStatement clbstmnt = con.prepareCall("{call totalStock}");
cs.executeQuery();
(c) StoreProcedureStatement spstmt = connection.createStoreProcedure
("totalStock()");
spstmt.executeQuery();
(d) PrepareStatement pstmt = connection.prepareStatement("totalStock)");
pstmt.execute();
ANSWER: B

You might also like