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. Because of the life cycle requirement for different type of values in java.
variables initialized and used in functions needs to be destructed with the execution of function and hence kept in stack. Same is applicable for the object references initialized within the method. If objects would have been created in stack, they wouldnt have been passed around across methods and hence they are created on heap.
So anything that is required beyond the scope of a method or function is kept on heap which is usually garbage collected by Java.
Help us improve. Please let us know the company, where you were asked this question :
Ans. instance variables and objects are stored on heap and the references are stored on stack whereas static variables are stored in the method area of heap.
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 :
Ans. You need to capture heap dump when it's in the healthy state. Start your application. Let it take real traffic for 10 minutes. At this point, capture heap dump. Heap Dump is basically the snapshot of your memory. It contains all objects that are residing in the memory, values stored in those objects, inbound
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 :