多选题 Given the following code segment:
public void validatePrime() {
long p = 17496; //'prime number' candidate
Double primeSquareRoot = Math.sqrt(p);
boolean isPrime = true;
for(long j = 2; j<= primeSquareRoot.longValue(); j++) {
if(p % j = = 0) {
// Print divisors
System.out.println(j+"X"+p/j);
isPrime = false;
}
}
System.out.println("Prime number: "+isPrime);
}
Which of the following is true? Hint: 17496 is not a prime number.
  • A. The code will not compile due to s syntactical error somewhere in the code.
  • B. The code will not compile since the expression (p % j == 0) should be written as ((p % j) == 0).
  • C. Divisors will be printed to standard out (for example, 2x8478, and so on), along with Prime number: false as the final output.
  • D. Divisors will be printed to standard out (for example, 2x8478, and so on), along with "Prime number: 0" as the final output.
【正确答案】 C
【答案解析】除数将会被打印到标准输出,紧随Prime number: false之后。对于好奇的读者,除数的完整列表打印如下:2x8748、3x5832、4x4374、6x2916、8x2187、9x1944、12x1458、18x972、24x729、27x648、36x486、54x324、72x243、81x216和108x162。A、B和D不正确。A不正确,因为在代码中没有语法错误。B不正确,因为围绕p%j的一对括号并不需要。D不正确,因为代码不会打印出字符0,它打印出布尔字面值false。