Questions from Starting Out With Java


Q: Write an if statement that assigns 0 to the variable b and

Write an if statement that assigns 0 to the variable b and assigns 1 to the variable c if the variable a is less than 10.

See Answer

Q: Write an if statement that displays “Goodbye†if the

Write an if statement that displays “Goodbye†if the variable myCharacter ­contains the character 'D'.

See Answer

Q: Write a JavaFX CSS style definition that will be applied to all

Write a JavaFX CSS style definition that will be applied to all Label controls. The style definition should specify the following: font size: 24, font style: italic, font weight: bold.

See Answer

Q: Write an if-else statement that assigns 20 to the variable

Write an if-else statement that assigns 20 to the variable y if the variable x is greater than 100. Otherwise, it should assign 0 to the variable y.

See Answer

Q: Write an if-else statement that assigns 1 to x when

Write an if-else statement that assigns 1 to x when y is equal to 100. Otherwise, it should assign 0 to x.

See Answer

Q: What will the following program segments display? 1. x

What will the following program segments display? 1. x = 2; y = x++; System.out.println(y); 2. x = 2; System.out.println(x++); 3. x = 2; System.out.println(−−x); 4. x = 8; y = x−−; System.ou...

See Answer

Q: Write a for loop that displays your name 10 times.

Write a for loop that displays your name 10 times.

See Answer

Q: Write a for loop that displays all of the odd numbers,

Write a for loop that displays all of the odd numbers, 1 through 49.

See Answer

Q: Write a for loop that displays every fifth number, zero through

Write a for loop that displays every fifth number, zero through 100.

See Answer

Q: Write a for loop that repeats seven times, asking the user

Write a for loop that repeats seven times, asking the user to enter a number. The loop should also calculate the sum of the numbers entered.

See Answer