Question 16 Value Variable Named Counter Statements Follow Executed Double Percent 054 Boo Q30592658

Question 16 What is the value of the variable named counterafter 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 Howmany lines are printed on the console when the following for loopis executed? for (int i = 2; i < 10; i++) {System.out.println(i); } a. 9 b. 10 c. 7 d. 8 2 points Question 18If number is 20, what is printed to the console after this code isexecuted? 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 speciald. 5 5 special e. 20 special 2 points Question 19 Which of thevalues below will not be printed to the console when this code isexecuted? 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 variablesnamed price and rate are doubles and qty is an int, what is apossible declaration for the getTax() method that’s called by thestatement that follows? double tax = TaxCalculator.getTax(price,rate, qty); a. static double getTax(double price, int qty, doublerate) b. static void getTax(double price, double rate, int qty) c.static double getTax(price, rate, qty) d. static doublegetTax(double x, double y, int z)

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *