Question 4
Back to Exercise
The program below does not compile. Which statement correctly describes the problem?
public class Main {
public static void main(String[] args) {
Long population = 1400;
System.out.println(population);
}
}
- A 1400 is too small for Long
- B An int is boxed only to Integer, and Integer is not a Long; write 1400L Correct
- C Long cannot hold numbers
- D population must be primitive
Correct Answer: Option B
long p = 1400; would compile (widening), but Long p = 1400; does not.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!