Exam 3: Decision Structures

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

What will be the value of bonus after the following code is executed? Int bonus, sales = 10000; If (sales < 5000) Bonus = 200; Else if (sales < 7500) Bonus = 500; Else if (sales < 10000) Bonus = 750; Else if (sales < 20000) Bonus = 1000; Else Bonus = 1250;

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

D

In most editors, you are indenting by one level each time that you press this key:

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

A

Which of the following correctly tests the char variable chr to determine whether it is NOT equal to the character B?

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

C

This type of operator determines whether a specific relationship exists between two values:

(Multiple Choice)
4.9/5
(37)

What would be the value of discountRate after the following statements are executed? Double discountRate = 0.0; Int purchase = 1250; Char cust = 'N'; If (purchase > 1000) If (cust == 'Y') DiscountRate = .05; Else DiscountRate = .04; Else if (purchase > 750) If (cust == 'Y') DiscountRate = .04; Else DiscountRate = .03; Else DiscountRate = 0;

(Multiple Choice)
4.9/5
(39)

In Java, when a character is stored in memory, it is actually stored as a(n):

(Multiple Choice)
4.9/5
(40)

A local variable's scope always ends at the closing brace of the block of code in which it is declared.

(True/False)
4.7/5
(28)

What will be the value of ans after the following code has been executed? Int x = 90, y = 55, ans = 10; If ( x == y); Ans *= 2;

(Multiple Choice)
4.8/5
(43)

When testing for character values, the switch statement does not test for the case of the character.

(True/False)
4.7/5
(35)

What is the value of ans after the following code has been executed? Int x = 40; Int y = 40; Int ans = 0; If (x = y) Ans = x + 10;

(Multiple Choice)
4.9/5
(35)

Which of the following will format 12.78 to display as 12.8%?

(Multiple Choice)
4.8/5
(31)

If str1 and str2 are both Strings, which of the following will correctly test to determine whether str1 is less than str2? (1) (str1 < str2) (2) (str1.equals(str2) < 0) (3) (str1.compareTo(str2) < 0)

(Multiple Choice)
4.8/5
(48)

What will be the values of ans, x, and y after the following statements are executed? Int ans = 35, x = 50, y =50; If ( x >= y) { Ans = x + 10; X -=y; } Else { Ans = y + 10; Y += x; }

(Multiple Choice)
4.9/5
(44)

What would be the value of discountRate after the following statements are executed? Double discountRate = 0.0; Int purchase = 1250; If (purchase > 1000) DiscountRate = .05; If (purchase > 750) DiscountRate = .03; If (purchase > 500) DiscountRate = .01; Else DiscountRate = 0;

(Multiple Choice)
4.8/5
(34)

What would be the value of bonus after the following statements are executed? Int bonus, sales = 85000; Char dept = 'S'; If (sales > 100000) If (dept == 'R') Bonus = 2000; Else Bonus = 1500; Else if (sales > 75000) If (dept == 'R') Bonus = 1250; Else Bonus = 1000; Else Bonus = 0;

(Multiple Choice)
4.9/5
(36)

A block of code is enclosed in a set of:

(Multiple Choice)
4.8/5
(32)

What will be the values of ans, x, and y after the following statements are executed? Int ans = 0, x = 15, y =25; If ( x >= y) { Ans = x + 10; X -=y; } Else { Ans = y + 10; Y += x; }

(Multiple Choice)
4.8/5
(35)

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

(Multiple Choice)
5.0/5
(39)

What would be the value of discountRate after the following statements are executed? Double discountRate; Char custType = 'B'; Switch (custType) { Case 'A': DiscountRate = .08; Break; Case 'B': DiscountRate = .06; Case 'C': DiscountRate = .04; Default: DiscountRate = 0.0; }

(Multiple Choice)
4.8/5
(35)

The System.out.printf method formats a string and displays it in the console window.

(True/False)
4.9/5
(34)
Showing 1 - 20 of 64
close modal

Filters

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