This is something you get better at with practice. There are lots of little compiler rules that you start to get familiar with as you go through the questions in the KB book and the mock exams found here. There are some situations (like using a variable that is out of scope) that you think it would make sense for the compiler to complain while reading through the code. Then there are other situations where you just have to memorize compiler/runtime rules (like calling wait() in a non-synchronized context will compile but throw a runtime exception) to determine what the error is. I have mostly seen compile warnings in questions involving generics (emphasis on the word mostly).
In short, it does take time, effort and patience (to not throw your PC out of the window) before you start to think like a Java compiler