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

(TCOs 1ñ6) The column names that are displayed in a JTable can be specified by u

ID: 2246647 • Letter: #

Question

(TCOs 1ñ6) The column names that are displayed in a JTable can be specified by using the _____ method of the DefaultTableModel.

.formatColumns

.setColumns

.setColumnNames

.setColumnIdentifiers

Flag this Question

Question 2 4 pts

(TCOs 1ñ6) What is the output of the code below?

double num = 56.4321;

System.out.printf("%.2f", 56.4321);

%.2f

%.2f56.4321

56.43

56.4321

Flag this Question

Question 3 4 pts

(TCOs 1ñ6) The signature of a method consists of

method name and parameter list.

return type

method name.

parameter list.

Flag this Question

Question 4 4 pts

(TCOs 1ñ6) Assume int[ ] t = {1, 2, 3, 4}. What is t.length?

5

4

0

3

Flag this Question

Question 5 4 pts

(TCOs 1 ,2, and 6) If a class contains a main method, that method is executed

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

Flag this Question

Question 6 4 pts

(TCOs 1ñ6) Invoking _____ returns the first element in an ArrayList x.

x.get(1)

x.get()

x.get(0)

x.first()

Flag this Question

Question 7 4 pts

(TCO 1, 4, and 6) The maximum number of radio buttons that can be selected within a ButtonGroup is

1.

2.

5.

all.

Flag this Question

Question 8 4 pts

(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;

}

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.

Flag this Question

Question 9 4 pts

(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]?

x.add("Chicago")

x.add(2, "Chicago")

x.add(0, "Chicago")

x.add(1, "Chicago")

Flag this Question

Question 10 4 pts

(TCOs 1, 5, and 6) The StringTokenizer method used to return the next field based on the delimiter character specified is

nextField.

nextToken.

Token.

Field.

Flag this Question

Question 11 4 pts

(TCOs 1ñ6) Which of the following statements causes the program to terminate when closing the frame?

frame.setDefaultCloseOperation(null)

frame.setDefaultCloseOperation(JFrame.STOP_ON_CLOSE)

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)

frame.setDefaultCloseOperation(JFrame.TERMINATE_ON_CLOSE)

Flag this Question

Question 12 4 pts

(TCOs 1, 5, and 6) Which type of exception occurs if the write method of BufferedWriter cannot write data to the file?

WriteException

IOException

FileIOException

FileException

Flag this Question

Question 13 4 pts

(TCOs 1ñ6) What layout manager should you use so that every component occupies the same size in the container?

any layout

a FlowLayout

a BorderLayout

a GridLayout

Flag this Question

Question 14 4 pts

(TCOs 1ñ6) The event handler (e.g., actionPerformed) is a method in

both source and listener object.

the EventObject class.

a listener object.

a source object.

Flag this Question

Question 15 4 pts

(TCOs 1ñ6) The _____ method of JOptionPane is used to display a message dialog box.

showMessage

displayMessageDialog

showMessageDialog

displayMessage

Flag this Question

Question 16 4 pts

(TCOs 1, 4, and 6) Menus are attached to windows by calling the _____ method.

addMenuBar

setJMenuBar

setMenu

addJMenuBar

Flag this Question

Question 17 4 pts

(TCOs 1ñ6) Suppose you wish to provide an accessor method for a double instance variable named percent, what should the signature method be?

public static void getPercent()

public double getPercent()

public int getPercent()

public void getPercent()

Flag this Question

Question 18 4 pts

(TCOs 1, 4, and 6) The method used to add panels to a JTabbedPane is

newTab.

newPanel.

addPanel.

addTab.

Flag this Question

Question 19 4 pts

(TCOs 1ñ6) A constructor cannot

be overloaded.

initialize variables to their defaults.

specify return types or return values.

have the same name as the class.

Flag this Question

Question 20 4 pts

(TCOs 1ñ6) Given the declaration Circle x = new Circle(), which of the following statements is most accurate?

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.

Flag this Question

Question 21 4 pts

(TCOs 1, 5, and 6) To add a database driver to a NetBeans project, you can add the JAR file for the driver to what folder?

The Source Packages folder

The Libraries folder

The Files folder

The Services folder

Flag this Question

Question 22 4 pts

(TCOs 1ñ6) _____ represents an entity in the real world that can be distinctly identified.

A class

An object

A data field

A method

Flag this Question

Question 23 4 pts

(TCOs 1ñ6) To execute the query "select * from Address" using the Statement object named stmt that has been properly configured with a database connection, use

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

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

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

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

Flag this Question

Question 24 4 pts

(TCOs 1ñ6) Suppose that your program accesses a MySQL database. Which of the following statements is false?

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

If the driver for MySQL database is not in the classpath, the program will have a runtime error, indicating that the driver class cannot be loaded.

If the driver for MySQL database is not in the classpath, the program will have a syntax error.

If the database connection cannot be made, a SQLException occurs.

Flag this Question

Question 25 4 pts

(TCOs 1ñ6) Which of the following statements is false?

PreparedStatement is for SQL SELECT statements only. You cannot create a PreparedStatement for SQL UPDATE statements.

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

PreparedStatement is efficient for repeated executions.

The first parameter in a perpared statement is number 1.

Flag this Question

Question 26 4 pts

(TCOs 1ñ6) Which method can be used to write data to a text file opened with the BufferedWriter object outfile?

outfile.newLine();

outfile.existLine();

Write(outfile);

outfile.write();

Flag this Question

Question 27 4 pts

(TCOs 1ñ6) Which type of exception occurs when creating a BufferedReader object for a nonexistent file?

FileNotExist

FileNotFound

FileNotExistException

FileNotFoundException

Flag this Question

Question 28 4 pts

(TCOs 1ñ6) Which class can be used to write data into a text file?

File

BufferedWriter

FileWrite

WriteFile

Flag this Question

Question 29 4 pts

(TCOs 1ñ6) Result set meta data are retrieved through

a Statement object.

a Connection object.

a ResultSet object.

a PreparedStatement object.

Flag this Question

Question 30 4 pts

(TCOs 1ñ6) Clicking a JCheckBox object generates _____ events.

ComponentEvent

ContainerEvent

ActionEvent

JCheckBoxEvent

Flag this Question

Question 31 4 pts

(TCOs 1ñ6) The method _____ gets the contents of the text field txtName.

txtName.findString()

txtName.getText(s)

txtName.getString()

txtName.getText()

Flag this Question

Question 32 4 pts

(TCOs 1ñ6) The method _____ appends a string s into the text area jta.

jta.appendText(s)

jta.append(s)

jta.setText(s)

jta.insertText(s)

Explanation / Answer

1. .set columnnames.

constructs a DefaultTableModel and initializes the table by passing data and columnnames to the SetDatvector method.

3.The signature of a method consists of the method name, parmeter profile, but not the return type. A class cannot have the methods with identical signature.

4.The t.length is 4.

5. When the object is created from the class

6. x.get(0)

7.The minimum number of radio buttons in a group is two and the maximm is seven.

8.An object of B contains data fields i,j,k,m.

9. x.add(1,"Chicago")

10. next token.

11. frame.setDefaultCloseOperation(jFrame.EXIT_ON_CLOSE)

12 .IOException.

13 . GridLayout.

14. the event object class.