Exam 4: Control Structures I: Selection

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

The execution of a break statement in a switch statement terminates the switch statement.

(True/False)
4.9/5
(30)

Based on the code above, what is the output if lastInitial = 'E'?

(Multiple Choice)
4.7/5
(39)

Suppose x = 10 and y = 20. The value of the expression ((x >= 10) && (y <= 20)) is true.

(True/False)
4.8/5
(30)

In Java, case and switch are reserved words, but break is not a reserved word.

(True/False)
4.8/5
(41)

The output of the Java code: int alpha = 5; int beta = 4; switch (beta) {case 2: alpha = alpha + 2; case 4: alpha = alpha + 4; break; case 6: alpha = alpha + 6; default: alpha = alpha + 10;} System.out.print(alpha); is: 9

(True/False)
4.8/5
(30)

After the execution of the following code, what will be the value of num if the input values are 0 3? (Assume that console is a Scanner object initialized to the standard input device.) int num = console.nextInt(); if (num > 0) num = num + 13; else if (num >= 3) num = num + 15;

(Multiple Choice)
4.8/5
(34)

In a ____ control structure, the computer executes particular statements depending on some condition(s).

(Multiple Choice)
4.8/5
(42)

Based on the code above, what is the value of y if x = 4?

(Multiple Choice)
4.9/5
(41)

Based on the code above, which part of the expression is not evaluated?

(Multiple Choice)
4.9/5
(30)

Which of the following is not a logical operator?

(Multiple Choice)
4.9/5
(45)

Which of the following is NOT a relational operator in Java?

(Multiple Choice)
4.8/5
(37)

Suppose str1 and str2 are String variables. The expression (str1 == str2) determines whether str1 and str2 point to the same String object.

(True/False)
4.9/5
(37)

When one control statement is located within another, it is said to be a controlled statement.

(True/False)
4.7/5
(35)

The expression !(x <= 0) is true only if x is a positive number.

(True/False)
4.7/5
(30)

Suppose that the input is 6 and console is a Scanner object initialized to the standard input device. Consider the following code. int alpha = 7; int beta = console.nextInt(); switch (beta) {case 5: alpha = alpha + 1; case 6: alpha = alpha + 2; case 7: alpha = alpha + 3; default: alpha = alpha + 5;} System.out.print(alpha); The output of this code is 9.

(True/False)
4.8/5
(33)

Suppose that you have the following statements. String str1 = "cat"; String str2 = "cats"; The statement str1.equals(str2); is true.

(True/False)
4.9/5
(35)

What is the output of the following Java code? int x = 0; if (x > 0) System.out.println("positive "); System.out.println("zero "); System.out.println("negative");

(Multiple Choice)
4.8/5
(30)

Which of the following has the highest value?

(Multiple Choice)
4.9/5
(37)

Two-way selection in Java is implemented using ____.

(Multiple Choice)
4.8/5
(27)

Based on the code above, what is the value of y if x = 1?

(Multiple Choice)
4.9/5
(45)
Showing 21 - 40 of 50
close modal

Filters

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