Exam 4: Control Structures I: Selection

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

Which of the following is a relational operator?

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

B

Suppose that x is an int variable. Which of the following expressions always evaluates to false?

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

C

Suppose P and Q are logical expressions. The expression P || Q is true if both P and Q are true.

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

True

All switch cases include a break statement.

(True/False)
4.9/5
(42)

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

(True/False)
4.9/5
(35)

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

(Multiple Choice)
4.8/5
(39)

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

(Multiple Choice)
4.8/5
(34)

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

(True/False)
4.7/5
(42)

Two-way selection in Java is implemented using ____.

(Multiple Choice)
4.8/5
(32)

Which of the following will cause a syntax error?

(Multiple Choice)
4.7/5
(27)

All switch structures include default cases.

(True/False)
4.7/5
(46)

int x, y;if (x 4) { If (x > 7) Y = 4; Else Y = 6; } Else Y = 8;Based on the code above, what is the value of y if x = 5?

(Multiple Choice)
4.8/5
(34)

A computer program will recognize both = and == as the equality operator.

(True/False)
4.9/5
(37)

In Java, || has a higher precedence than &&.

(True/False)
4.8/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
(46)

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

(True/False)
4.8/5
(36)

'A' = 7 || 4 What is the value of the expression above?

(Multiple Choice)
4.8/5
(33)

Which of the following has the highest value?

(Multiple Choice)
4.7/5
(38)

In Java, !, &&, and || are called logical operators.

(True/False)
4.9/5
(44)

switch (lastInitial) { Case 'A': System.out.println("section 1"); Break; Case 'B': System.out.println("section 2"); Break; Case 'C': System.out.println("section 3"); Break; Case 'D': System.out.println("section 4"); Break; Default: System.out.println("section 5"); }Based on the code above, what is the output if lastInitial = 'E'?

(Multiple Choice)
4.9/5
(36)
Showing 1 - 20 of 50
close modal

Filters

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