What is the output of the following code?
1 2 3 4 5 |
|
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
In Java, the addition operator "+" operates from left to right .
For this problem, this becomes 1 0 + 2 0 + "30" + 4 0 + 5 0 = 3 0 + "30" + 4 0 + 5 0 (arithmetical addition) = "3030" + 4 0 + 5 0 (integer-string concatenation) = "303040" + 5 0 (integer-string concatenation) = "30304050" (integer-string concatenation)