Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. (TCOs 1–6) The data displayed in a JTable can be provided by a _____ object.

ID: 3822930 • Letter: 1

Question

1. (TCOs 1–6) The data displayed in a JTable can be provided by a _____ object. (Points : 4) TableModel GridModel DefaultTableModel TableGridModel Question 2. 2. (TCOs 1–6) What is the output of the code below? double num = 56.4321; System.out.printf("%.2f", 56.4321); (Points : 4) %.2f %.2f56.4321 56.43 56.4321 Question 3. 3. (TCOs 1–6) Arguments to methods always appear within (Points : 4) brackets. parentheses. quotation marks. curly braces. Question 4. 4. (TCOs 1–6) Assume int[ ] t = {1, 2, 3, 4}. What is t.length? (Points : 4) 5 4 0 3 Question 5. 5. (TCOs 1 ,2, and 6) If a class contains a main method, that method is executed (Points : 4) automatically when the class is run. when another method within the class calls it. when an object is created from the class. None of the above Question 6. 6. (TCOs 1–6) Invoking _____ returns the first element in an ArrayList x. (Points : 4) x.get(1) x.get() x.get(0) x.first() Question 7. 7. (TCOs 1, 4, and 6) Consider a form with a ButtonGroup with three radio buttons, and two check boxes. What is the total number of radio buttons and check boxes that can be selected at any time? (Points : 4) 5 4 3 2 Question 8. 8. (TCOs 1–6) Which statements are most accurate regarding the following classes? class A { private int i; protected int j; } class B extends A { private int k; protected int m; } (Points : 4) An object of B contains data fields j, m. An object of B contains data fields j, k, m. An object of B contains data fields k, m. An object of B contains data fields i, j, k, m. Question 9. 9. (TCOs 1–6) Suppose ArrayList x contains two strings [Beijing, Singapore]. Which of the following methods will cause the list to become [Beijing, Chicago, Singapore]? (Points : 4) x.add("Chicago") x.add(2, "Chicago") x.add(0, "Chicago") x.add(1, "Chicago") Question 10. 10. (TCOs 1, 5, and 6) Which statement sets up a tokens object that will use the % as a field delimiter? (Points : 4) tokens = StringTokenizer(inputString, "%"); tokens = new StringTokenizer(inputString, "%"); tokens = StringTokenizer("%", inputString); tokens = new StringTokenizer("%", inputString); Question 11. 11. (TCOs 1–6) The title of a JFrame can be set by using which statement in the constructor of your class that extends JFrame? (Points : 4) super(“Title here”); setFrameTitle(“Title here”); setTitleFrame(“Title here”); JFrame.super(“Title here”); Question 12. 12. (TCOs 1, 5, and 6) Which type of exception occurs if the write method of BufferedWriter cannot write data to the file? (Points : 4) WriteException IOException FileIOException FileException Question 13. 13. (TCOs 1–6) Suppose a JFrame uses the GridLayout(0, 2). If you add six buttons to the frame, how many rows are displayed? (Points : 4) 2 3 1 4 Question 14. 14. (TCOs 1–6) The interface _____ should be implemented to listen for a button action event. (Points : 4) FocusListener ContainerListener ActionListener WindowListener Question 15. 15. (TCOs 1–6) The _____ method of JOptionPane is used to display a message dialog box. (Points : 4) showMessage displayMessageDialog showMessageDialog displayMessage Question 16. 16. (TCOs 1 ,4, and 6) A JMenu component can contain one or more _____ components. (Points : 4) JMenuItem JMenuBar FileMenu BarMenu Question 17. 17. (TCOs 1–6) When implementing a method, use the class’s set and get methods to access the class’s _____ data. (Points : 4) public private protected All of them Question 18. 18. (TCOs 1, 4, and 6) Each tab of a JTabbedPane is assigned an index; the first tab has an index of (Points : 4) -1. 0. 1. 2. Question 19. 19. (TCOs 1–6) A constructor cannot (Points : 4) be overloaded. initialize variables to their defaults. specify return types or return values. have the same name as the class. Question 20. 20. (TCOs 1–6) Given the declaration Circle x = new Circle(), which of the following statements is most accurate? (Points : 4) x contains an int value. You can assign an int value to x. x contains an object of the Circle type. x contains a reference to a Circle object.

Explanation / Answer

Q1. Table Model

By using Table Model object we display the data in the JTable

Q2. 56.432

Because we specified access specifier as %3f which results in printing the value with upto precion 3.

Q3. Paranthesis

We pass the arguments within the method.

Q4. 4

As the array is having only 4 values. The length of the array will show 4 only.

Q5) None

Because main method id the method which starts execution first

Q6) x.get(0)

This retrieves the first element from the array