InterviewSolution
| 1. |
What Is String Pool? Where Is It Created In Memory? |
|
Answer» When String literals are created they are stored in a String pool and that is a COMMON pool; which means if there are two strings literals having the same content then those string will share the space in the pool. When String object is created by ASSIGNING a string literal, pool will be checked to verify if there is any existing object with the same content if there is then that existing reference is used, no new object is created in that CASE. If no object is found with the same content then this new literal will be added in the pool. String pool is stored in the HEAP. When String literals are created they are stored in a String pool and that is a common pool; which means if there are two strings literals having the same content then those string will share the space in the pool. When String object is created by assigning a string literal, pool will be checked to verify if there is any existing object with the same content if there is then that existing reference is used, no new object is created in that case. If no object is found with the same content then this new literal will be added in the pool. String pool is stored in the heap. |
|