Question:

What will be the output of the following Java statements:
(a) System.out.println ("30 + 20");
(b) System.out.println ("Information Technology" + 802);

Show Hint

In Java, anything inside double quotes is treated as a string. Use + for string concatenation.
Updated On: Jul 14, 2025
Hide Solution
collegedunia
Verified By Collegedunia

Solution and Explanation

In this statement, the expression "30 + 20" is enclosed in double quotes, making it a string literal.
Java treats it as plain text and does not evaluate the arithmetic operation inside the quotes.
Therefore, the output will be the string itself.
Output: 30 + 20
In this case, the string "Information Technology" is concatenated with the integer 802.
Java automatically converts the integer into a string and joins it with the preceding text.
This process is called string concatenation.
So, the result is a single string formed by joining both parts.
Output: Information Technology802
Was this answer helpful?
0
0