And if there are no else if or else statements anywhere below, it would optimize to this:
if(cmp_str5 == 0)
Compiling without optimization would add a few bytes (I don't know how many) to the compiled object code, plus a very slight increase at runtime if it needlessly evaluated an expression. Running it on a regular computer or a modern phone or even on one of the larger microchips, the difference would be negligible, but I've programmed some of the smaller microchips where every single byte counted (i.e. the executable had to be 16K or even less) and the compiler was sometimes smart enough to catch and throw out the unnecessary comparisons. Java compilers catch unreachable statements and potentially uninitialized references, so potentially, with the right flags and the right compiler, the compiler would hopefully issue a warning for code such as yours, but it wouldn't issue an error because your code is perfectly legal. If you tell the compiler to treat warnings as errors, it would issue an error.