The following Java code contains variables a, b, and C, respectively, in the memory () store.
class a{ private String a = "a"; Public Boolean MethodB () { = "BB"; Final String c = "CC"; } }
A: Heap area, heap area, heap area
B: Heap area, stack area, heap area
C: Heap area, stack area, stack area
D: Heap area, heap area, stack area
E: Static zone, stack area, heap area
F: Static zone, stack area, stack area
Analytical:
A belongs to the member variable of Class A. The string a = "AA" involves an object instance to allocate memory to "AA" on the heap. In-depth understanding of Java Virtual Machines Java heap Area The only purpose is to hold object instances where almost all object instances allocate memory.
The virtual machine stack in the in-depth understanding of Java virtual Machines describes the memory model that the Java method executes: Each method creates a stack frame to store the local variable table, the operand stack, the dynamic link list, the method exit, and so on. Each method from the invocation until the completion of the process corresponds to a stack frame in the virtual machine stack into the stack of the process.
The local variable table holds the various basic data types known to the compiler (Boolean, Byte, char, short, int, float, long, double), object reference (reference type, which is not equivalent to the object itself, It may be a reference pointer to the start address of the object, or it may point to a handle representing the object or other location associated with the object, and the ReturnAddress type, which points to the address of a bytecode directive. Note: The base data type does not include string. Here you can be sure that the b variable is stored in the memory stack storage area.
The final modifier string feels a bit redundant because the string itself is a final type , so the c variable is stored in the memory stack store.
Share this method, do not know that this understanding is right, if there are problems to discuss together.
2015 Ali Internship Java development on the machine pen questions