How many String objects will be created

“Fred” and “47” will come from the string literal pool. As such they won’t be created when the method is invoked. Instead they will be put there when the class is loaded (or earlier, if other classes use constants with the same value).

“Fred47”, “ed4” and “ED4” are the 3 String objects that will be created on each method invocation.

Leave a Comment