Exam 3: Decision Structures

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

In an if/else statement, if the boolean expression is False:

(Multiple Choice)
4.7/5
(36)

What will be printed when the following code is executed? Double x = 45678.259; System.out.printf("%,.2f", x);

(Multiple Choice)
4.8/5
(36)

What does the following code display? Double x = 12.3798146; System.out.printf("%.2f\n", x);

(Multiple Choice)
4.7/5
(45)

What would be the value of x after the following statements were executed? Int x = 10; Switch (x) { Case 10: X += 15; Case 12: X -= 5; Break; Default: X *= 3; }

(Multiple Choice)
4.7/5
(42)

To do a case insensitive compare which of the following could be used to test the equality of two strings, str1 and str2?

(Multiple Choice)
4.8/5
(36)

What will be the value of pay after the following statements are executed? Int hours = 45; Double pay, payRate = 10.00; Pay = hours <= 40 ? Hours * payRate : 40 * payRate + (hours - 40) * payRate * 1.5;

(Multiple Choice)
4.7/5
(44)

What would be the value of bonus after the following statements are executed? Int bonus, sales = 1250; If (sales > 1000) Bonus = 100; If (sales > 750) Bonus = 50; If (sales > 500) Bonus = 25; Else Bonus = 0;

(Multiple Choice)
4.7/5
(43)

What is the value of ans after the following code has been executed? Int x = 35; Int y = 20, ans = 80; If (x < y); Ans += y;

(Multiple Choice)
4.9/5
(47)

Which of the following expressions will determine whether x is less than or equal to y?

(Multiple Choice)
4.8/5
(36)

Which of the following is the correct boolean expression to test for: int x being a value between, but not including, 500 and 650, or int y not equal to 1000?

(Multiple Choice)
4.8/5
(31)

In a switch statement, each of the case values must be unique.

(True/False)
4.8/5
(34)

The if/else statement will execute one group of statements if its boolean expression is true or another group if its boolean expression is False.

(True/False)
4.8/5
(30)

These operators use two operands:

(Multiple Choice)
4.8/5
(40)

If str1 and str2 are both Strings, which of the following expressions will correctly determine whether they are equal? (1)(str1 == str2) (2) str1.equals(str2) (3)(str1.compareTo(str2) == 0)

(Multiple Choice)
4.7/5
(36)

A Boolean expression is one that is either:

(Multiple Choice)
4.9/5
(38)

Which one of the following is the not equal operator?

(Multiple Choice)
4.9/5
(33)

What will be the value of x after the following code is executed? Int x = 75; Int y = 60; If (x > y) X = x - y;

(Multiple Choice)
4.9/5
(33)

Because the && operator performs short-circuit evaluation, your boolean expression will usually execute faster if the subexpression that is most likely False is on the left of the && operator.

(True/False)
4.8/5
(31)

If chr is a character variable, which of the following if statements is written correctly?

(Multiple Choice)
4.7/5
(35)

An important style rule you should adopt for writing if statements is to write the conditionally executed statement on the line after the if statement.

(True/False)
4.8/5
(37)
Showing 21 - 40 of 64
close modal

Filters

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