int a = 1L;
won't compile and int b = 0;
b += 1L;
compiles fine. Explain me why?

Submitted by: Muhammad
When += is used, that's a compound statement and the compiler internally casts it. Whereas in the first case, the compiler straightaway shouts at you since it is a direct statement.

Compiler behavior and statement types can be confusing, so questions like this will test a candidate's grasp of these concepts.
Submitted by: Muhammad

Read Online Java Software Engineer Job Interview Questions And Answers