Question 2
Back to Exercise
The program below does not compile. Which statement correctly describes the problem?
public class Main {
public static void main(String[] args) {
int stock = null;
System.out.println(stock);
}
}
- A stock must be final
- B A primitive int cannot hold null; use Integer if "no value" is needed, or a real number such as 0 Correct
- C println cannot print int
- D null must be in quotes
Correct Answer: Option B
javac: "incompatible types:
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!