Given the code fragment:
Which statement is true?
Given the code fragment:
Which statement is true?
The code will not compile because the Random class, ArrayList class, and List interface are part of the java.util package, which needs to be explicitly imported. The Math class is part of the java.lang package, which is automatically imported. Therefore, importing java.util.* at the beginning of the code will resolve the compilation errors.
The correct answer is D
The correct answer is D. Random has to be imported explicitly from java.util.*
Correct answer is D. We must import Random, ArrayList and List from java.util
public static void main(String[] args)
It does not compile because of a syntax error in main method declaration: use parentheses instead of curly braces
D is the correct answer.
java.lang.Math has to be imported in order to use Math.PI, correct answer is D