117k views
1 vote
What is the output of the following statement?

System.out.println("1 + 2\\"
+ "3 - 4\\" + "=\\" + (1 + 2)
+ "\\" + (3 + 4));

1 Answer

6 votes

Answer:

1 + 2

3 - 4

=

3

7

Step-by-step explanation:

1 + 2 (it print the string "1+2" and goes to a new line

3 - 4 (it print the string "3-4" and goes to a new line)

= (it print the string "=" and goes to a new line)

3 (it perform arithmetic operation on 1+2 to give 3)

( It create empty new line)

7. (it perform arithmetic operation on 3+4 to give 7)

User Liam Williams
by
6.2k points