Must both right-hand expressions of a ternary operator be of compatible types? : <p>My Practice Tests book contains this question on the ternary operator:</p>

<pre><code>// What is the output of the following application?
public class Transportation {
    public static String travel(int distance) {
        return(distance &lt; 1000 ? "train" : 10);
    }
    public static void main(String[] args) {
        travel(500);
    }
}
</code></pre>

<p>It does not compile. The explanation given is the following:</p>

<blockquote>
  <p>Ternary operations require both right-hand expressions to be of
  compatible data types. In this example, the first right-hand
  expression of the outer ternary operation is of type String, while the
  second right-hand expression is of type int. Since these data types
  are incompatible, the code does not compile, and Option C is the
  correct answer.</p>
</blockquote>

<p>Is that really the reason? It looks to me like this example doesn't compile because 10 is not a String and a String is what the method must return.
I'm asking because 
<code>System.out.println(distance &lt; 1000 ? "train" : 10);</code>
compiles and runs without a problem.</p>
