Here is a Java puzzle from Neal Gafter's presentation.
Which one is correct, a, b, c or d?
The answer is d.
There are 3 defects in this program:
1. Apparently, there is no "break" in the switch statement.
2. nextInt(2) will only return 0 or 1.
3. 'P', 'G', 'M' are Chars, not Strings. So it uses the wrong constructor.
There are more puzzles in the book below, if you want to do more.
<pre><code> String foo = "bar"; </code></pre>