多选题
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.