title: Why does '(int)(char)(byte)-2' produce 65534 in Java?
body: <p>I encountered this question in technical test for a job. Given the following code example:</p>
  
  <pre><code>public class Manager {
      public static void main (String args[]) {
          System.out.println((int) (char) (byte) -2);
      }
  }
  </code></pre>
  
  <p>It gives the output as 65534.</p>
  
  <p>This behavior shows for negative values only; 0 and positive numbers yield the same value, meaning the one entered in SOP. The byte cast here is insignificant; I have tried without it.</p>
  
  <p>So my question is: what exactly is going on here?</p>