A

Admin • 833K Points
Coach

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.
  • Correct Answer - Option(A)
  • Views: 19
  • Filed under category Java
  • Hashtags:

Explanation by: Admin

The two String variables str1 and str2 are concatenated using the + operator, which results in the combined string “helloworld”.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.