Question 1
What is the output of the following program? ```java public class Main { public static void main(String[] args) { RuntimeException e = new RuntimeException("top"); System.out.println(e.getMessage() + " " + e.getCause()); } } ```
A. top followed by an empty string
getCause returns null, which concatenation renders as the literal text null, not an empty string.
B. top nullCorrect answer
Correct: the message is present and the absent cause concatenates as the text null.
C. top top
The cause is not the message; without a supplied cause it is null.
D. An exception is thrown because the cause was never set
Building the exception does not require a cause or throw over a missing one.
Explanation
Constructing an exception does not throw it; it is ordinary object creation. With no cause supplied, getCause returns null, which string concatenation renders as the text null.