What is the result of the following?
public static void main(String... args) { String name = "A"; int _number = 001; boolean a$; System.out.println(name + " won. " + _number + " profit? " + a$); }
D.
Variables are allowed to start with an underscore and are allowed to contain a $.
Therefore, all the variable declarations compile, making Options A, B, and C incorrect.
However, the println()
refers to the uninitialized local boolean.
Since local variables are not automatically initialized, the code does not compile, and Option D is correct.