click below
click below
Normal Size Small Size show me how
Module 05: Ch 3.pt.2
Quiz ITP 120
| Question | Answer |
|---|---|
| What will be printed when the following code is executed? double x = 45678.259; System.out.printf("%,.2f", x); | 45,678.26 |
| What will be printed when the following code is executed? double x = 45678.259; String output = String.format("%,.1f", x); System.out.println(output); | 45,678.3 |
| What will be the value of ans after the following code has been executed? | 120 |
| What will be the value of bonus after the following code is executed? | 1000 |
| 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; | 15 |
| What will be the values of ans, x, and y after the following statements are executed? | ans = 60, x =0, y =50 |
| What will be the values of ans, x, and y after the following statements are executed? | ans = 35, x = 15, y = 40 |
| What would be the value of bonus after the following statements are executed? | 25 |
| What would be the value of bonus after the following statements are executed? | 1000 |
| What would be the value of discountRate after the following statements are executed? | 0.0 |
| What would be the value of discountRate after the following statements are executed? | .01 |
| What would be the value of discountRate after the following statements are executed? | .04 |
| What would be the value of x after the following statements were executed? | 20 |
| Which of the following correctly tests the char variable chr to determine whether it is NOT equal to the character B? | if (chr != 'B') |
| Which of the following expressions will determine whether x is less than or equal to y? | x <= y |
| 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? | See Slide |
| 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? | See Slide |
| Which of the following will format 12.78 to display as 12.8%? | System.out.printf("%.1f%%", 12.78); |
| Which of the following will format 12.7801 to display as $12.78? | System.out.printf("$%,.2f", 12.7801); |
| Which one of the following is the not equal operator? | != |