Given: class Feline { public static void main(String[] args) { Long x = 42L; Long y = 44L; System.out.print(" " + 7 + 2 + " "); System.out.print(foo() + x + 5 + " "); System.out.println(x + y + foo()); } static String foo() { return "foo"; } } What is the result?
-
9 foo47 86foo
-
9 foo47 4244foo
-
9 foo425 86foo
-
9 foo425 4244foo
-
72 foo47 86foo
-
72 foo425 86foo
F
Correct answer
Explanation
String concatenation is left‑to‑right. The first print yields a space, then 7 and 2 become "72" surrounded by spaces. The second print concatenates "foo", 42 and 5 giving "foo425" plus a trailing space. The final println adds 42+44=86 to "foo" producing "86foo". Hence the output matches "72 foo425 86foo".