Questions from Starting Out With Java


Q: Find the error: // Force a call to the paint

Find the error: // Force a call to the paint method paint();

See Answer

Q: Find the error: private class MyMouseListener implements MouseListener {

Find the error: private class MyMouseListener implements MouseListener { public void mouseClicked(MouseEvent e) { mouseClicks += 1; } }

See Answer

Q: The following import statements are in a controller class that uses a

The following import statements are in a controller class that uses a Button component and a Label component. import java.fxml.FXML; import java.scene.control.Button; import java.scene.control.Label;...

See Answer

Q: The following pseudocode algorithm has an error. The program is supposed

The following pseudocode algorithm has an error. The program is supposed to ask the user for the length and width of a rectangular room, and then display the room’s area. The program must multiply t...

See Answer

Q: There are a number of syntax errors in the following program.

There are a number of syntax errors in the following program. Locate as many as you can. */ What's wrong with this program /* public MyProgram { public static void main(String[ ] args) ; } int a, b, c...

See Answer

Q: Find the errors in the following code: // Warning!

Find the errors in the following code: // Warning! This code contains ERRORS! if (num2 == 0) System.out.println("Division by zero is not possible."); System.out.println("Please run the program again...

See Answer

Q: Find the errors in the following code: // Warning!

Find the errors in the following code: // Warning! This code contains ERRORS! if (x == 1) ; y = 2 ; else if (x == 2) ; y = 3 ; else if (x == 3) ; y = 4 ;

See Answer

Q: Find the errors in the following code: The following statement

Find the errors in the following code: The following statement should determine whether x is not greater than 20. What is wrong with it? if (!x > 20)

See Answer

Q: 11. When determining whether a number is inside a range,

11. When determining whether a number is inside a range, it’s best to use this operator. 1. && 2. ! 3. | | 4. ? : 12. This determines whether two different String objects contain the same string. 1...

See Answer

Q: Write the code to add the following RadioButton controls to the ToggleGroup

Write the code to add the following RadioButton controls to the ToggleGroup. RadioButton radio1 = new RadioButton("Option 1"); RadioButton radio2 = new RadioButton("Option 2"); RadioButton radio3 = ne...

See Answer