Question: Question 16 What is the value of the variable named counter after the statements that follow are executed? double percent = 0.54; boolean valid =
Question 16 What is the value of the variable named counter after the statements that follow are executed? double percent = 0.54; boolean valid = true; int counter = 1; if ((percent > 0.50) && (valid == true)) { counter += 2; if (valid == true) { counter++; } else if (percent >= 0.50){ counter += 3; } } else { counter++; } a. 4 b. 7 c. 3 d. 2 2 points Question 17 How many lines are printed on the console when the following for loop is executed? for (int i = 2; i < 10; i++) { System.out.println(i); } a. 9 b. 10 c. 7 d. 8 2 points Question 18 If number is 20, what is printed to the console after this code is executed? for (int i = 3; i <= number; i += 2) { if (number % i == 0) { System.out.println(i); if (i == number) { System.out.println("special"); } break; } } a. 5 b. 2 c. 5 special d. 5 5 special e. 20 special 2 points Question 19 Which of the values below will not be printed to the console when this code is executed? for (int i = 0; i < 3; i++) { for (int j = 0; j < 2; j++) { if (i == j) { continue; } System.out.println("i = " + i + " j = " + j); } } a. i = 0 j = 1 b. i = 1 j = 1 c. i = 1 j = 0 d. i = 2 j = 1 e. i = 2 j = 0 2 points Question 20 If the variables named price and rate are doubles and qty is an int, what is a possible declaration for the getTax() method thats called by the statement that follows? double tax = TaxCalculator.getTax(price, rate, qty); a. static double getTax(double price, int qty, double rate) b. static void getTax(double price, double rate, int qty) c. static double getTax(price, rate, qty) d. static double getTax(double x, double y, int z)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
