In which memory a String is stored, when we create a string using new operator?
A. Stack
B. String memory
C. Heap memory
D. Random storage space
Answer:C
In which memory a String is stored, when we create a string using new operator?
A. Stack B. String memory C. Heap memory D. Random storage space
Explanation: When a String is created using a new operator, it always created in the heap memory. Whereas when we create a string using double quotes, it will check for the same value as of the string in the string constant pool. If it is found, returns a reference of it else create a new string in the string constant pool.