More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know.
Ans. 1. Stack Segment - Contains primitives, Class / Interface names and references.
2. Heap Segment - Contains all created objects in runtime, objects only plus their object attributes (instance variables), Static variables are also stored in heap.
3. Code Segment - The segment where the actual compiled Java bytecodes resides when loaded
Help us improve. Please let us know the company, where you were asked this question :
Ans. String pool (String intern pool) is a special storage area in Java heap. When a string is created and if the string already exists in the pool, the reference of the existing string will be returned, instead of creating a new object and returning its reference.
Help us improve. Please let us know the company, where you were asked this question :
Ans. member variable are loaded into heap, so they are initialized with default values when an instance of a class is created. In case of local variables, they are stored in stack until they are being used.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Stack memory areas is used to hold method and local variables while objects are always allocated memory in the heap. The heap memory is shared between multiple threads whereas Stack memory isn't.
Help us improve. Please let us know the company, where you were asked this question :
Each thread has a private stack, which it can quickly add and remove items from. This makes stack based memory fast, but if you use too much stack memory, as occurs in infinite recursion, you will get a stack overflow.
Help us improve. Please let us know the company, where you were asked this question :