uh, did you ever think of actually executing it?
It will print "5bc"
because + works both as arithmetic as well as concatenation operator. And all the expressions are executed from left to right. So in case of 2 + 3 + "bc" it first adds 2 and 3 acting as arithmetic operator and then when it finds string on one side and number on other at that time it acts as concatenation operator. So,
print(2+3+"bc") prints 5bc
print("bc"+2+3) prints bc23
It's always a good idea to read the language documentation ...
What does this statement print? System.out.println(5 + "bc");
3 answers
because + works both as arithmetic as well as concatenation operator. And all the expressions are executed from left to right. So in case of 2 + 3 + "bc" it first adds 2 and 3 acting as arithmetic operator and then when it finds string on one side and number on other at that time it acts as concatenation operator. So,
print(2+3+"bc") prints 5bc
print("bc"+2+3) prints bc23
print(2+3+"bc") prints 5bc
print("bc"+2+3) prints bc23
print(2+3+"bc") prints 5bc