Exam 4: Control Structures I: Selection

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

Based on the code above, what is the value of x?

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

C

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

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

C

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

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

C

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

(Multiple Choice)
4.8/5
(45)

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

(True/False)
4.8/5
(30)

The operators = and == have the same order of precedence.

(True/False)
4.9/5
(41)

What is the output of the following Java code? int x = 57; int y = 3; switch (x % 9) {case 0: case 1: y++; case 2: y = y - 2; break; case 3: y = y + 2; case 4: break; case 5: case 6: y = y + 3;} System.out.println(y);

(Multiple Choice)
5.0/5
(35)

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

(True/False)
5.0/5
(40)

Suppose that you have the following statements. int score; String grade; if (score >= 65) grade = "pass"; else grade = "fail"; If score is equal to 75, the value of grade is pass.

(True/False)
4.8/5
(37)

=! is a relational operator.

(True/False)
4.7/5
(36)

Suppose P and Q are logical expressions. The logical expression P && Q is false if both P and Q are false.

(True/False)
4.8/5
(37)

The expression 'A' <= 'B' evaluates to false while the expression 'A' < 'B' evaluates to true.

(True/False)
4.9/5
(31)

The symbol >= is a logical operator.

(True/False)
4.9/5
(37)

The conditional operator ?: takes ____ arguments.

(Multiple Choice)
4.8/5
(39)

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

(True/False)
4.8/5
(36)

Suppose that you have the following code. int num = 10; if (num > 10) System.out.println(num); else System.out.println(num + 5); The output of this code is 5.

(True/False)
4.8/5
(38)

Which of the following will cause a syntax error, if you are trying to compare x to 5?

(Multiple Choice)
4.8/5
(35)

Which of the following will cause a syntax error?

(Multiple Choice)
4.9/5
(39)

What does >= mean?

(Multiple Choice)
4.9/5
(33)

What is the value of the expression above?

(Multiple Choice)
4.8/5
(42)
Showing 1 - 20 of 50
close modal

Filters

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