2015 Ali Internship Java development on the machine pen questions

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.