Given:
class Main { //w w w . ja v a2 s . c o m public static void main(String[] args) { long x = 42L; long y = 44L; System.out.print(" " + 7 + 2 + " "); System.out.print(bar() + x + 5 + " "); System.out.println(x + y + bar()); } static String bar() { return "bar"; } }
What is the result?
G is correct.
Concatenation runs from left to right.
If either operand is a String, the operands are concatenated.
If both operands are numbers, they are added together.