Exam 6: More Conditionals and Loops

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

How many times will the System.out.println("*"); statement execute inside of the following nested for loops? for(j = 0; j < 10; j++) For(k = 10; k > j; k--) System.out.println("*");

Free
(Multiple Choice)
4.9/5
(39)
Correct Answer:
Verified

C

A conditional operator is virtually the same as a switch statement.

Free
(True/False)
4.8/5
(36)
Correct Answer:
Verified

False

The do loop differs from the while loop in that

Free
(Multiple Choice)
4.8/5
(30)
Correct Answer:
Verified

B

Code Example Ch 06-1 In the following example, x is an int: switch (x) { case 3 : x += 1; case 4 : x += 2; case 5 : x += 3; case 6 : x++; case 7 : x += 2; case 8 : x--; case 9 : x++ } -Refer to Code Example Ch 06-1: If x is equal to 5, what will the value of x be after the switch statement executes?

(Multiple Choice)
4.9/5
(29)

Control in a switch statement jumps to the first matching case.

(True/False)
4.8/5
(31)

Which of the following statements are true about Java loops?

(Multiple Choice)
4.9/5
(45)

How many times will the following nested loop structure execute the innermost statement (x++;)? for(int j = 0; j < 100; j++) For(int k = 100; k > 0; k--) X++;

(Multiple Choice)
4.8/5
(38)

Write a do loop to obtain a list of scores from a teacher. The teacher should end input by entering the sentinel value, 999. The program should output the average of the scores.

(Essay)
4.8/5
(38)

Write code that outputs all of the int values between 1 and 100 with five values per line, and each of those five values spaced out equally. Use a single for loop to solve this problem.

(Essay)
4.8/5
(36)

The following for loop is an infinite loop:: for(int j = 0; j < 1000;) i++;

(True/False)
4.8/5
(40)

A for statement is normally used when you do not know how many times the loop should be executed.

(True/False)
4.8/5
(39)

The following for loop is odd in that the loop increment value changes during iterations of the loop. Determine the number of times the loop iterates and the final value of j after the loop terminates. int k = 0; for (j = 0; j < 20; j += k) k++;

(Short Answer)
4.9/5
(39)

If a break occurs within the innermost loop of a nested loop that is three levels deep,

(Multiple Choice)
4.9/5
(34)

A continue statement

(Multiple Choice)
4.9/5
(37)

A loop can be used in a GUI to draw concentric circles.

(True/False)
4.9/5
(32)

In Java, it is possible to create an infinite loop out of while and do loops but not for loops.

(True/False)
4.8/5
(34)

How many times will the following loop iterate? int x = 10; Do { System.out.println(x); X--; } while(x > 0);

(Multiple Choice)
4.8/5
(41)

The following loop is syntactically valid: for(int j = 0; j < 1000; j++) j--;

(True/False)
4.8/5
(33)

Which of the following would rotate an Ellipse named lipse 30 degrees counterclockwise?

(Multiple Choice)
4.8/5
(37)

Code Example Ch 06-1 In the following example, x is an int: switch (x) { case 3 : x += 1; case 4 : x += 2; case 5 : x += 3; case 6 : x++; case 7 : x += 2; case 8 : x--; case 9 : x++ } -Refer to Code Example Ch 06-1: If x is equal to 3, what will the value of x be after the switch statement executes?

(Multiple Choice)
4.8/5
(34)
Showing 1 - 20 of 35
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)