Java MCQ: How many String objects will be created in the following code?
a) 1
b) 2
c) 3
d) 4
Answer:
a) 1
Explanation:
When a String is created using a string literal, only one String object is created in the string pool, if no other object with the same content exists.
Reference links:
https://www.rameshfadatare.com/learn-java-programming/
https://www.javaguides.net/p/java-tutorial-learn-java-programming.html