asked 6.7k views
0 votes
Show what this program prints. Be exact and complete. Can you explain the behavior of each print statement? 1 2 3 4 5 6 7 public class Test { public static void main(String[] args) { System.out.println("39 + 3"); System.out.println(39 + 3); System.out.println("39" + 3); } }

1 Answer

0 votes

Answer:

39 + 3

42

393

Step-by-step explanation:

In this line System.out.println("39 + 3"), the quotation marks are used to delimit a string, then when printed in the console the string is printed as-is.

In the next line: System.out.println(39 + 3), without the quotation marks, the 39+3 is treated as a normal addition and prints the result of the operation.

In the last line printed with the code System.out.println("39" + 3,; the symbol + is used to concatenate the string 39 with the number 3, since the string has no spaces they are printed together.

answered
User Hanleyhansen
by
7.6k points

Related questions

Welcome to Qamnty — a place to ask, share, and grow together. Join our community and get real answers from real people.