Multiple choice technology web technology

When a string literal is used in the program, Java automatically creates instances of the string class.

  1. True

  2. False

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

String literals are not automatically created as new instances. When Java encounters a string literal, it first checks the string pool. If the literal already exists in the pool, it returns the reference to that existing string. Only a new literal not found in the pool creates a new instance.