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".
Loading...
Related Quiz
- ReentrantLock belongs to the ______ package in Java.
- Which interface or class should a class use or extend to create a new thread in Java?
- What is the primary difference between StringBuilder and StringBuffer classes in Java?
- Consider a scenario where an application retrieves a large amount of data from a database and displays it in a UI paginated form. How would you efficiently manage and optimize data retrieval and display using JDBC?
- Which of the following primitive data types has the largest size in memory?