title: When does type checking happen in Java
body: <p>I have a question in my homework that looks like this. </p>
  
  <p>Which of the following process happens ONLY during compilation time in Java?</p>
  
  <p>(i) type inference – inferring the type of a variable whose type is not specified.<br>
  (ii) type erasure – replacing a type parameter of generics with either Object or its bound.<br>
  (iii) type checking – checking if the value matches the type of the variable it is assigned to.  </p>
  
  <p>A. Only (i)<br>
  B. Only (i) and (ii)<br>
  C. Only (i) and (iii)<br>
  D. Only (ii) and (iii)<br>
  E. (i), (ii), and (iii) </p>
  
  <p>From my understanding, Java only performs type checks for generics during compile time, hence (i) and (ii) are definitely correct. However, I am unsure about type checking, and from the description provided it does not seem like type checking is not limited to generics, but other things as well. </p>
  
  <p>The solution to this question is B, but there was no explanation given. I was wondering then, when does type checking happen? If it does not only happen during compile time, does it happen during both compile time and runtime, or only during runtime, and why? </p>