What will be the output of the following code snippet: System.out.println("2" + 3);?

  • "23"
  • "5"
  • 23
  • Compilation error
In this code snippet, Java performs string concatenation when you use the '+' operator with a string and another data type. So, "2" + 3 results in "23". The integer 3 is automatically converted to a string and then concatenated with "2".
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *