Questions from Starting Out With Java


Q: The intention of the following statement is to give the panel object

The intention of the following statement is to give the panel object a GridLayout manager with 10 columns and 5 rows: panel.setLayout(new GridLayout(10, 5));

See Answer

Q: The panel variable references a JPanel object. The intention of the

The panel variable references a JPanel object. The intention of the following statement is to create a titled border around panel: panel.setBorder(new BorderFactory("Choices"));

See Answer

Q: Find the error in the following SQL statement. SELECT *

Find the error in the following SQL statement. SELECT * FROM Coffee WHERE Description = "French Roast Dark”

See Answer

Q: Find the error in the following Java code. Assume that conn

Find the error in the following Java code. Assume that conn references a valid Connection object. // This code has an error!!! String sql = "SELECT * FROM Coffee"; Statement stmt = conn.createStatemen...

See Answer

Q: Find the error: // Create a read-only text

Find the error: // Create a read-only text field. JTextField textField = new JTextField(10); textField.setEditable(true);

See Answer

Q: Find the error: // Create a JList and add it

Find the error: // Create a JList and add it to a scroll pane. // Assume that array already exists. JList list = new JList(array) ; JScrollPane scrollPane = new JScrollPane(); scrollPane.add(list) ;

See Answer

Q: Find the error: JLabel label = new JLabel("Have

Find the error: JLabel label = new JLabel("Have a nice day!"); label.setImage(image) ;

See Answer

Q: Find the error: // Create a text area with 20

Find the error: // Create a text area with 20 columns and 5 rows. JTextArea textArea = new JTextArea (20, 5);

See Answer

Q: An application has a Button control named calcButton. Write the statement

An application has a Button control named calcButton. Write the statement that assigns the ID "calc-button" to the calcButton control.

See Answer

Q: Find the error: Find the error:

See Answer