posted 21 years ago
I would say that there are THREE string objects created during the compile time, "java", "exam", " " and one string object created at runtime, "java exam".
However, if you declare s1 and s2 as final, then there would still THREE string objects created during compile time, but they are "java", "exam" and "java exam". And there will be no objects created at runtime.