Answers

Question and Answer:

  Home  Java Software Engineer

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

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.

 146 views

More Questions for you: