Questions from Starting Out With Java


Q: Assume the following variable declaration exists in a program: double

Assume the following variable declaration exists in a program: double number = 1234567.456; Write a statement that uses System.out.printf to display the value of the number variable formatted as: 1,23...

See Answer

Q: Assume gridPane is the name of a GridPane container, and button

Assume gridPane is the name of a GridPane container, and button is the name of a Button control. Write a statement that adds button to gridPane at column 2, row 5.

See Answer

Q: Write an if statement that assigns 0.2 to commission if

Write an if statement that assigns 0.2 to commission if sales is greater than or equal to 10000.

See Answer

Q: Assume the following variable declaration exists in a program: double

Assume the following variable declaration exists in a program: double number = 123.456; Write a statement that uses System.out.printf to display the value of the number variable rounded to one decimal...

See Answer

Q: Assume the following variable declaration exists in a program: double

Assume the following variable declaration exists in a program: double number = 123.456; Write a statement that uses System.out.printf to display the value of the number variable padded with leading ze...

See Answer

Q: Assume the following variable declaration exists in a program: int

Assume the following variable declaration exists in a program: int number = 123456; Write a statement that uses System.out.printf to display the value of the number variable in a field that is 10 spac...

See Answer

Q: Assume the following variable declaration exists in a program: double

Assume the following variable declaration exists in a program: double number = 123456.789; Write a statement that uses System.out.printf to display the value of the number variable left-justified, wit...

See Answer

Q: Assume the following declaration exists in a program: String name

Assume the following declaration exists in a program: String name = "James"; Write a statement that uses System.out.printf to display the value of name in a field that is 20 spaces wide.

See Answer

Q: Write an if statement that sets the variable fees to 50 if

Write an if statement that sets the variable fees to 50 if the boolean variable max is true.

See Answer

Q: Write an if statement that assigns 20 to the variable y and

Write an if statement that assigns 20 to the variable y and assigns 40 to the ­variable z if the variable x is greater than 100.

See Answer