Introduction to Java Programming, Includes Data Structures, Eleventh Edition, Y. Daniel Liang

This quiz is for students to practice. A large number of additional quiz is available for instructors using Quiz Generator from the Instructor's Resource Website. Videos for Java, Python, and C++ can be found at https://yongdanielliang.github.io/revelvideos.html.

Chapter 35 Advanced Database Programming


Section 35.3 Batch Processing
35.1  To add the SQL statement "insert into T values (100, 'Smith')" into the batch into a Statement stmt, use
A. stmt.add("insert into T values (100, 'Smith')");
B. stmt.add('insert into T values (100, 'Smith')');
C. stmt.addBatch("insert into T values (100, 'Smith')");
D. stmt.addBatch('insert into T values (100, 'Smith')');

35.2  Invoking executeBatch() returns ________.
A. an int value indicating how many SQL statements in the batch have been executed successfully.
B. a ResultSet
C. an array of counts, each of which counts the number of the rows affected by the SQL command.
D. an int value indicating how many rows are effected by the batch execution.

Section 35.4 Scrollable and Updateable Result Set
35.3  To obtain a scrollable or updateable result set, you must first create a statement using which of the following?
A. Statement statement = connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
B. Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
C. Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
D. Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);

35.4  In a scrollable and updateable result set, you can use ___________ methods on a result set.
A. first()
B. last()
C. insertRow()
D. deleteRow()
E. updateRow()

Section 35.5 RowSet, JdbcRowSet, and CachedRowSet
35.5  RowSet is an extension of _______.
A. Connection
B. Statement
C. ResultSet
D. CLOB

35.6  You can use a RowSet to __________.
A. set a database URL
B. set a database username
C. set a database password
D. set a SQL query statement

35.7  You may create a RowSet using __________.
A. new RowSet()
B. new JdbcRowSet()
C. new CachedRowSet()
D. new JdbcRowSetImpl()
E. new CachedRowSetImpl()

35.8  To move the cursor to the 2nd row in a RowSet, use _________.
A. next(2)
B. first()
C. next()
D. absolute(2)
E. last()

35.9  To update a String column in a RowSet, use _________.
A. updateString("newValue")
B. updateString("columnName", "newValue")
C. updateString("newValue", "columnName")
D. updateObject("newValue", "columnName")

35.10  To commit the changes in a CachedRowSet, use ___________.
A. commint()
B. acceptChanges()
C. acceptUpdates()
D. refresh()

Section 35.6 RowSetTableModel
35.11  For a JTable to be synchronized with a JDBC RowSet, you may create a table model with the following features:
A. The model should extend AbstractTableModel and implement getRowCount(), getColumnCount(), and getValueAt(int row, int column).
B. The model should implement RowSetListener and the methods rowSetChanged(RowSetEvent e), rowChanged(RowSetEvent e), cursorMoved(RowSetEvent e).
C. You should invoke fireTableStructureChanged() method from rowSetChanged(RowSetEvent e) and rowChanged(RowSetEvent e) to synchronize changes in the RowSet with the the JTable

35.12  The index of row and column in JTable is 0-based. The index of row and column in RowSet is 1-based.
A. true
B. false

Section 35.7 Storing and Retrieving Images in JDBC
35.13  You can store images in a database using data type _______.
A. varchar2
B. varchar
C. BLOB
D. CLOB

35.14  You can store large text in a database using data type _______.
A. varchar2
B. varchar
C. BLOB
D. CLOB

35.15  You can store large text in a database using data type _______.
A. varchar2
B. varchar
C. BLOB
D. CLOB

35.16  To get binary data from a column, use _____________ in Statement.
A. getBlob()
B. getBinaryStream()
C. getBinaryData()
D. getData()

35.17  To set binary data to a column, use _____________ in Statement.
A. setBlob()
B. setBinaryStream()
C. setBinaryData()
D. setData()