It doesn't. It effects how much optimization the compiler is able to do.
When a and b are final, the compiler recognizes that a + b is a compile time constant, calculates its value and puts the result into the byte code.
So, the difference between your two code examples is that the first executes the concatenation at runtime, whereas the second executes it at compile time.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus