Name:_______________________



Name:_______________________

Covers Chs 36-37 |Sample Exam | |

Multiple Choice Questions Only for This Test

Part I: Questions: (1 pts each)

1  Which of the following statements are true?

A. To create a tree model, you may first create an instance of TreeNode to represent the root of the tree, and then create an instance of DefaultTreeModel fitted with the root.

B. DefaultTreeModel is a concrete implementation for TreeModel that uses TreeNode.

C. TreeModel contains the structural information about the tree, and tree data are stored and managed by TreeNode.

D. The TreeModel interface represents the entire tree. Unlike the ListModel or TableModel, the tree model does not directly store or manage tree data.



You can create a JTable using __________.

A. new JTable(new DefaultTableModel())

B. new JTable()

C. new JTable(4, 5)

D. new JTable(new Integer[3][4], new Integer[4])

3  You can create a JTree using __________.

A. new JTree()

B. new JTree(new DefaultTreeModel())

C. new JTree(new Object[]{"red", "green", "blue"})

D. new JTree(new Vector())

4  The data in DefaultTableModel are stored in ___________.

A. an array

B. a LinkedList

C. a Vector

D. an ArrayList

5  DefaultTableModel contains the methods for

A. adding a column

B. removing a row

C. removing a column

D. inserting a new row

E. adding a new row

6  The autoResizeMode property specifies how columns are resized (you can resize table columns but not rows). Possible values are:

A. JTable.AUTO_RESIZE_OFF

B. JTable.AUTO_RESIZE_NEXT_COLUMN

C. JTable.AUTO_RESIZE_ALL_COLUMNS

D. JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS

E. JTable.AUTO_RESIZE_LAST_COLUMN

7  _________ are the properties in JTable.

A. rowCount

B. columnCount

C. rowHeight

D. rowMargin

E. gridColor

8  DefaultTableModel contains the methods for

A. removing a column

B. inserting a new row

C. adding a column

D. removing a row

E. adding a new row

9  _________ are the properties in JTable.

A. rowHeight

B. columnCount

C. rowMargin

D. gridColor

E. rowCount

10  The data in DefaultTableModel are stored in ___________.

A. an ArrayList

B. an array

C. a Vector

D. a LinkedList

11  The autoResizeMode property specifies how columns are resized (you can resize table columns but not rows). Possible values are:

A. JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS

B. JTable.AUTO_RESIZE_NEXT_COLUMN

C. JTable.AUTO_RESIZE_ALL_COLUMNS

D. JTable.AUTO_RESIZE_LAST_COLUMN

E. JTable.AUTO_RESIZE_OFF

12  _________ are the properties in JTable.

A. selectionForeground

B. selectionMode

C. selectionBackground

D. showGrid

E. model

13  You can create a JTree using __________.

A. new JTree(new Object[]{"red", "green", "blue"})

B. new JTree()

C. new JTree(new DefaultTreeModel())

D. new JTree(new Vector())

14  Invoking Class.forName method may throw ___________.

A. ClassNotFoundException

B. RuntimeException

C. IOException

D. SQLException

15  What information may be obtained from a DatabaseMetaData object?

A. maximum number of connections to the database

B. JDBC driver name and version

C. maximum table name length and maximum number of columns in a table

D. database URL and product name

16  Which of the following are interfaces?

A. Statement

B. DriverManager

C. ResultSet

D. Connection

17 

In a relational data model, _________ defines the representation of the data.

A. SQL

B. Structure

C. Language

D. Integrity

18  Which of the following statements are true?

A. You may load multiple JDBC drivers in a program.

B. You may create multiple connections to a database.

C. You may create multiple statements from one connection.

D. You can send queries and update statements through a Statement object.

19  Which of the following statements loads the JDBC-ODBC driver?

A. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver")

B. Class.forName(sun.jdbc.odbc.JdbcOdbcDriver)

C. Class.loadClass("sun.jdbc.odbc.JdbcOdbcDriver")

D. Class.loadClass(sun.jdbc.odbc.JdbcOdbcDriver)

20  To create a statement on a Connection object conn, use

A. Statement statement = conn.createStatement();

B. Statement statement = conn.statement();

C. Statement statement = Connection.createStatement();

D. Statement statement = connection.create();

21  SQL ________ statements may change the contents of a database.

A. INSERT

B. SELECT

C. DELETE

D. UPDATE

22  A database URL for an access database source test is ________.

A. jdbcodbc:test

B. jdbc:odbc:test

C. test

D. sun.jdbc:odbc:test

23  Database meta data are retrieved through ____________.

A. a Connection object

B. a PreparedStatement object

C. a Statement object

D. a ResultSet Object

24  What is the return value from

      stmt.executeUpdate("insert into T values (100, 'Smith')")

A. an int value indicating how many rows are effected from the invocation

B. void

C. a value indicating whether the SQL statement has been executed successfully

D. an object that contains the status of the execution

25  ________ are known as intra-relational constraints, meaning that a constraint involves only one relation.

A. Domain constraints

B. Primary key constraints

C. Foreign key constraints

26  A database URL for a MySQL database named test on host panda.armstrong.edu is ________.

A. jdbc:mysql:/panda.armstrong.edu/test

B. jdbc.mysql://panda.armstrong.edu/test

C. jdbc:mysql://panda.armstrong.edu/test

D. jdbc.mysql.//panda.armstrong.edu/test

27  In a relational data model, _________ imposes constraints on the data.

A. Language

B. Structure

C. SQL

D. Integrity

28  To execute a SELECT statement "select * from Address" on a Statement object stmt, use

A. stmt.executeUpdate("select * from Address");

B. stmt.executeQuery("select * from Address");

C. stmt.query("select * from Address");

D. stmt.execute("select * from Address");

29  _________ specify the permissible values for an attribute.

A. Domain constraints

B. intra-relational constraints

C. Primary key constraints

D. inter-relational constraints

E. Foreign key constraints

30  Suppose that your program accesses MySQL or Oracle database. Which of the following statements are true?

A. If the database is not available, the program will have a runtime error, when attempting to create a Connection object.

B. If the database is not available, the program will have a syntax error.

C. If the driver for MySQL and Oracle are not in the classpath, the program will have a runtime error, indicating that the driver class cannot be loaded.

D. If the driver for MySQL and Oracle are not in the classpath, the program will have a syntax error.

31  What information may be obtained from a ResultSetMetaData object?

A. number of rows in the result set

B. JDBC driver name and version

C. number of columns in the result set

D. database URL and product name

32  ________ is an attribute or a set of attributes that uniquely identifies the relation.

A. A primary key

B. A key

C. A superkey

D. A candidate key

33  Which of the following statements are true?

A. PreparedStatement is for SQL query statements only. You cannot create a PreparedStatement for SQL update statements.

B. PreparedStatement is efficient for repeated executions.

C. The parameters in a prepared statement is denoted using the ? sign.

D. PreparedStatement is a subinterface of Statement

34  Where is com.mysql.jdbc.Driver located?

A. in the standard Java library bundled with JDK

B. in a JAR file classes12.jar

C. in a JAR file mysqljdbc.jar

35  Analyze the following code:

     ResultSet resultSet = statement.executeQuery

       ("select firstName, mi, lastName from Student where lastName "

         + " = 'Smith'");

     System.out.println(resultSet.getString(1));

A. resultSet.getString(1) returns the mi field in the result set.

B. The program will have a runtime error, because the cursor in resultSet does not point to a row. You must use resultSet.next() to move the cursor to the first row in the result set. Subsequently, resultSet.next() moves the cursor to the next row in the result set.

C. If the SQL SELECT statement returns no result, resultSet is null.

D. resultSet.getString(1) returns the firstName field in the result set.

36  In a relational data model, ________ provides the means for accessing and manipulating data.

A. Structure

B. Language

C. Integrity

D. SQL

37  To connect to a local MySQL database named test, use

A. Connection connection = DriverManager.getConnection(jdbc:mysql://localhost/test);

B. Connection connection = DriverManager.getConnection("jdbc:mysql://localhost/test");

C. Connection connection = DriverManager.connect("jdbc:mysql://localhost/test");

D. Connection connection = DriverManager.getConnection("mysql:jdbc://localhost/test");

38  Result set meta data are retrieved through ____________.

A. a Connection object

B. a PreparedStatement object

C. a Statement object

D. a ResultSet Object

Keys:

1. ABCD

2. ABCD

3. ABCD

4. C

5. ADE

6. ABCDE

7. ABCDE

8. BCE

9. ABCDE

10. C

11. ABCDE

12. ABCDE

13. ABCD

14. A

15. ABCD

16. ACD

17. B

18. ABCD

19. A

20. A

21. ACD

22. B

23. A

24. A

25. AB

26. C

27. D

28. B

29. A

30. AC

31. C

32. C

33. BCD

34. C

35. BD

36. BD

37. B

38. D

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download