The following method is intended to print the number of digi…

The following method is intended to print the number of digits in the parameter num. public int numDigits(int num){ int count = 0; while (/* missing condition */) { count++; num = num / 10; } return count;} Which of the following can be used to replace / * missing condition */ so that the method will work as intended?

A teacher put three bonus questions on a test and awarded 5…

A teacher put three bonus questions on a test and awarded 5 extra points to anyone who answered all three bonus questions correctly and no extra points otherwise. Assume that the boolean variables bonusOne, bonusTwo, and bonusThree indicate whether a student has answered the particular question correctly. Each variable was assigned true if the answer was correct and false if the answer was incorrect. Which of the following code segments will properly update the variable grade based on a student’s performance on the bonus questions? I.if(bonusOne && bonusTwo && bonusThree) grade += 5;II.if(bonusOne || bonusTwo || bonusThree) grade += 5;III.if(bonusOne) grade += 5;if(bonusTwo) grade += 5;if(bonusThree) grade += 5;

Consider the following code segment. The code is intended to…

Consider the following code segment. The code is intended to read nonnegative numbers and compute their product until a negative number is read; however, it does not work as intended. (Assume that the readlnt method correctly reads the next number from the input stream.) int k = 0;int prod = 1;while (k >= 0){ System.out.print(“enter a number: “); k = readInt(); // readInt reads the next number from input prod = prod * k;}System.out.println(“product: ” + prod); Which of the following best describes the error in the program?

Consider the following method. public static void message(in…

Consider the following method. public static void message(int a, int b, int c){ if (a < 10) { if (b < 10) { System.out.print("X"); } System.out.print("Y"); } if (c < 10) { if (b > 10) { System.out.print(“Y”); } else { System.out.print(“Z”); } }} What is printed as a result of the call message (5, 15, 5) ?