Questions from Starting Out With Java


Q: Assume x is an int variable, and rand references a Random

Assume x is an int variable, and rand references a Random object. What does the following statement do? x = rand.nextInt(100);

See Answer

Q: Assume x is an int variable, and rand references a Random

Assume x is an int variable, and rand references a Random object. What does the following statement do? x = rand.nextInt(9) + 1;

See Answer

Q: Assume x is a double variable, and rand references a Random

Assume x is a double variable, and rand references a Random object. What does the following statement do? x = rand.nextDouble();

See Answer

Q: Match the conditional expression with the if-else statement that performs

Match the conditional expression with the if-else statement that performs the same operation. 1. q = x < y ? a + b : x * 2 ; 2. q = x < y ? x * 2 : a + b; 3. q = x < y ? 0 : 1; if (x < y)  q = 0; el...

See Answer

Q: How many times will "I love Java programming!" be printed

How many times will "I love Java programming!" be printed in the following program segment? int count = 0; while (count < 10) System.out.println("I love Java programming!);

See Answer

Q: Write an input validation loop that asks the user to enter a

Write an input validation loop that asks the user to enter a number in the range of 10 through 24.

See Answer

Q: Write an input validation loop that asks the user to enter â

Write an input validation loop that asks the user to enter ‘Y’, ‘y’, ‘N’, or ‘n’.

See Answer

Q: Write an input validation loop that asks the user to enter â

Write an input validation loop that asks the user to enter “Yes†or “Noâ€.

See Answer

Q: Name the three expressions that appear inside the parentheses in the for

Name the three expressions that appear inside the parentheses in the for loop’s header.

See Answer

Q: You want to write a for loop that displays “I

You want to write a for loop that displays “I love to program†50 times. Assume that you will use a control variable named count. 1. What initialization expression will you use? 2. What test expres...

See Answer