What does this statement print?
System.out.println(“bc”+2+3)
bc23
because the string is evaluated first, setting the expression type.
print(2+3+"bc") would print 5bc
you know, you could always just execute the statement ...
The statement "System.out.println("bc" + 2 + 3)" prints the following output:
bc23
Explanation:
In Java, the "+" operator is used for both addition (numeric) and concatenation (string) depending on the operands involved.
In this case, we have a combination of strings and numbers:
1. The first operand is the string "bc".
2. The second operand is the number 2.
When a number is concatenated with a string, it gets converted into a string automatically.
3. The third operand is the number 3.
Similarly, it will be converted into a string.
So, when we concatenate these elements together, the output will be the concatenation of the strings "bc" and "23", resulting in "bc23".