To obtain data from a table
To obtain data from a table, you _____ the database. (Points : 4) select query get None of the above Which SQL keyword is used to merge rows from multiple tables? (Points : 4) JOIN INNER JOIN GROUP MERGE Pattern matching in a SQL query is performed with which clause? (Points : 4) FROM. WHERE. SELECT. LIKE. When joining tables, the _____ clause specifies the columns from each table that are com¬pared to determine which rows are merged. (Points : 4) ON WHERE LIKE GROUP Question 5. 5. (TCO 7) Which statement is false? (Points : 4) A DELETE statement removes rows from a table. A DELETE statement must specify the table from which to delete. A DELETE statement starts with the keyword DELETE. A WHERE clause must be present in a DELETE statement. Question 6. 6. (TCO 7) Classes and interfaces for the JDBC API can be found in which package? (Points : 4) java.jdbc javax.jdbc java.sql java.sql.jdbc Question 7. 7. (TCO 7) The _____ interface configures the database connection and prepares query statements automatically. (Points : 4) ResultSet RowSet Both of the above Neither of the above Question 8. 8. (TCO 7) Transaction processing enables a program to _____ or _____ a transaction based on whether the transaction was successful. (Points : 4) save; delete commit; rollback save; rollback commit; delete Question 9. 9. (TCO 7) Transaction processing enables a program to treat a database operation, or set of operations, as a single operation. This is known as a(n) _____ or a(n) _____ (Points : 4) atomic operation; unique operation. unique operation; transaction. atomic operation; transaction. None of the above Question 10. 10. (TCO 2) How many String objects are instantiated by the following code segment (not including the literals)? String s1, output; s1 = “hello”; output = “nThe string reversed is: ” ; for ( int i = s1.length() – 1; i >= 0; i– ) output += s1.charAt( i ) + ” ” ; (Points : 4) 1 4 5 7 Question 11. 11. (TCO 2) For String c = “Now is the time for all”; The Java statements String i = c.substring( 7 ); String j = c.substring( 4, 15 ); will result in (Points : 4) i = “he time for all” and j = “is the time”. i = “the time for all” and j = “s the time”. i = “the time for all” and j = “is the time “. i = “he time for all” and j = “s the time”. Question 12. 12. (TCO 2) Which of the following is not a method of class String? (Points : 4) toUpperCase trim toCharacterArray All of the above are methods of class String. Question 13. 13. (TCO 2) Given the following declarations: StringBuilder buffer = new StringBuilder( “Testing Testing” ); buffer.setLength( 7 ); buffer.ensureCapacity( 5 ); Which of the following is true? (Points : 4) buffer has capacity 5 buffer has capacity 31 buffer has content “Testin” buffer has length 15 Question 14. 14. (TCO 2) Which of the following creates the string of the numbers from 1 to 1,000 most efficiently? (Points : 4) String s; for ( int i = 1; i <= 1000; i++ ) s += i; StringBuilder sb = new StringBuilder( 10 ); for ( int i = 1; i <= 1000; i++ ) sb.append( i ); String s = new String( sb ); StringBuilder sb = new StringBuilder( 3000 ); for ( int i = 1; i <= 1000; i++ ) sb.append( i ); String s = new String( sb ); All are equivalently efficient. Question 15. 15. (TCO 2) Which of the following statements is true? (Points : 4) Class Matcher provides methods find, lookingAt, replaceFirst, and replaceAll. Method matches (from class String, Pattern, or Matcher) will return true only if the entire search object matches the regular expression. Methods find and lookingAt (from class Matcher) will return true if a portion of the search object matches the regular expression. All of above Question 16. 16. (TCO 6) How many comparisons will the linear search algorithm make if the search key is not in an array of 10 elements? (Points : 4) 0 10 9 5 Question 17. 17. (TCO 6) A(n) _____ allows a program to walk through the collection and remove elements from the collection. (Points : 4) Set Queue Iterator List Question 18. 18. (TCO 6) Iterator method _____ determines whether the Collection contains more elements. (Points : 4) hasNext next contains containsNext Question 19. 19. (TCO 3) What happens when an end-of-file marker is reached (and the program is using an ObjectInputStream to read data from a file)? (Points : 4) Nothing occurs An end-of-file character is read by the program Method readObject returns the value 0 An EOFException is thrown Question 20. 20. (TCO 2) The first argument to method showMessageDialog specifies (Points : 4) the title. the message. the icon. the parent window. Question 21. 21. (TCO 2) Superclass methods with this level of access cannot be called from subclasses. (Points : 4) private public protected package 1. (TCO 2) Polymorphism enables you to (Points : 4) program in the general. program in the specific. absorb attributes and behavior from previous classes. hide information from the user. Question 2. 2. (TCO 2) Assigning a subclass reference to a superclass variable is safe (Points : 4) because the subclass object has an object of its superclass. because the subclass object is an object of its superclass. only when the superclass is abstract. only when the superclass is concrete. Question 3. 3. (TCO 2) A(n) class cannot be instantiated. (Points : 4) final concrete abstract polymorphic Question 4. 4. (TCO 2) Declaring a method final means (Points : 4) it will prepare the object for garbage collection. it cannot be accessed from outside its class. it cannot be overloaded. it cannot be overridden. Question 5. 5. (TCO 2) A class that implements an interface but does not declare all of the interface’s methods must be declared (Points : 4) public. interface. abstract. final. Question 6. 6. (TCO 4) When an exception occurs, it is said to have been (Points : 4) caught. thrown. declared. handled. Question 7. 7. (TCO 4) An uncaught exception (Points : 4) is a possible exception that never actually occurs during the execution of the program. is an exception that occurs for which the matching catch clause is empty. is an exception that occurs for which there are no matching catch clauses. is another term for a thrown exception. Question 8. 8. (TCO 4) Which of the following statements is false? (Points : 4) A finally block is placed after the last catch block. A finally block typically releases resources acquired in the corresponding try block. The finally block and try block can appear in any order. A finally block is optional. Question 9. 9. (TCO 4) When an unchecked exception occurs in a method but is not caught (Points : 4) the method-call stack is unwound. the method terminates. all local variables in that method go out of scope. All of the above Question 10. 10. (TCO 4) Java SE 7’s multicatch enables you to catch multiple exception types in a single catch handler and perform the same task for each type of exception. The syntax for a multicatch is (Points : 4) catch ( Type1 or Type2 or Type3 e ). catch ( Type1 e1 | Type2 e2 | Type3 e3 ). catch ( Type1 | Type2 | Type3 e ). catch ( Type1 e1 or Type2 e2 or Type3 e ). Question 11. 11. (TCO 1) The text “Hello there, my friend” is an example of what type of capitalization? (Points : 4) Sentence-style capitalization Book-title capitalization Neither of the above Both of the above Question 12. 12. (TCO 1) Which of the following statements about Swing GUI components is false? (Points : 4) Swing components are less portable but more flexible than the original Java GUI components from package java.awt. Most Swing components are written completely in Java. Swing components allow the user to specify a uniform look-and-feel across all platforms. Swing components allow the user to change the look-and-feel while the program is running. Question 13. 13. (TCO 1) Which of the following statements about a JLabel is false? (Points : 4) Applications rarely change a label’s contents after creating it. A JLabel can display text and an image. A JLabel can display text and a button. A JLabel is a subclass of JComponent. Question 14. 14. (TCO 1) A JLabel can be attached to a JFrame using method (Points : 4) attach. contain. append. add. Question 15. 15. (TCO 1) Which of the following most completely describes the steps for setting up event handling for a GUI component? (Points : 4) Create a class that represents the event handler, attach the JFrame to a JWindow object, and register the event handler. Implement an appropriate event-listener interface and register the event handler. Create a class that represents the event handler and implement an appropriate event-listener interface. Create a class that represents the event handler, implement an appropriate event-listener interface, and register the event handler. Question 16. 16. (TCO 1) Forgetting to register an event-handler object for a particular GUI component’s event type causes (Points : 4) events of that type to be ignored. all of the GUI component’s events to be ignored. a compilation error. None of the above Question 17. 17. (TCO 1) Which of the following is not necessary to use the event delegation model? (Points : 4) An event listener must be registered. An event handler must be implemented. The appropriate interface must be implemented. The appropriate interface must be registered. Question 18. 18. (TCO 1) How many event-listener interfaces correspond to each event type? (Points : 4) one two one or more zero Question 19. 19. (TCO 1) Which method determines if a JCheckBox is selected? (Points : 4) isSelected getSelected selected None of the above Question 20. 20. (TCO 1) The setMaximumRowCount method is used for (Points : 4) Button. JComboBox. JRadioButton. JToggleButton. Question 21. 21. (TCO 1) Method getSelectedValues of class JList returns (Points : 4) an array of ints representing the indices of the selected items. an array of doubles representing the indices of the selected items. an array of Strings representing the selected items. an array of Objects representing the selected items. Question 22. 22. (TCO 1) BorderLayout implements interface (Points : 4) ActionListener. FlowLayout. Layout. LayoutManager2. 1. (TCO 8) Your program is running without an error but produces strange results when the user clicks a button Calculate. You suspect that you have made a logical error in a method that defines action for this button. Explain how you would set up watch variables. (Points : 11) 2. Java has different types of exceptions, including the I/O exceptions, run-time exceptions, and checked exceptions. Explain the difference between these types of exceptions and give an example of when each one may occur. (Points : 11) 3. Give several reasons why exception-handling techniques should not be used for conventional program control. 4. An ArrayList class is similar to an array in that it stores elements that can be accessed using an integer index that starts at 0. Explain the main difference between these two structures, and give an example of when using one is better than the other. (Points : 11) 5. Suppose that you have an array of baseball scores (type integer) called Scores. The values in the array are ordered from largest to smallest. You need to find the average score, how many scores are less or equal to the average, and how many are greater than the average. Write a code fragment to accomplish it, or at the very least, write a detailed plan (pseudocode). 6. Is formatting program output important? If so, what are the predefined Java formatting methods to control formatting for numbers, percent values, and currencies? List a coding example that uses these methods to format a currency value. 7. Class and object are the building blocks of object-oriented programming languages. What are some of the key characteristics of an object?