What will be the output of the following code snippet: System.out.println(10 + 20 + "Hello" + 30 + 40);?
- 100200Hello3040
- 1020Hello3040
- 5070Hello
- Hello10203040
In Java, when you use the + operator with both numbers and strings, it performs left-to-right addition. So, the numbers are added first, and then the result is concatenated with the strings. The correct output is "1020Hello3040."
Loading...
Related Quiz
- What is the worst-case time complexity of Linear Search?
- Which method is used to submit a task for execution to the ExecutorService and returns a Future object?
- What will happen if an exception is not caught by any catch block?
- Imagine you are developing a real-time multiplayer online game where player data needs to be synchronized. What strategy and technology would you choose for networking communication?
- Considering a real-world scenario where a thread pool is being used to manage multiple client requests to a server, what could be the potential issues if the thread pool size is too small or too large? How would you determine an optimal thread pool size?