0 votes
in JAVA by
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

1 Answer

0 votes
by

(c) Heap memory

Reason: 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.

...