Q. What is the output of the following code?

Code:
String str1 = “hello”;
String str2 = “world”;
System.out.println(str1 + str2);
  • (A) “helloworld”
  • (B) “hello world”
  • (C) “hello” “world”
  • (D) There is a syntax error in the code.
πŸ’¬ Discuss
βœ… Correct Answer: (A) “helloworld”
Explanation: The two String variables str1 and str2 are concatenated using the + operator, which results in the combined string “helloworld”.
Explanation by: Deepak Sahoo
The two String variables str1 and str2 are concatenated using the + operator, which results in the combined string “helloworld”.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
243
Total Visits
πŸ“½οΈ
3 y ago
Published
πŸŽ–οΈ
Deepak Sahoo
Publisher
πŸ“ˆ
93%
Success Rate