Java Exercise 10.25
1.
In fact, this problem examines the two same two small one big principle: The method name is the same, the parameter type is same
The subclass return type is less than or equal to the parent class method return type.
Subclass throws exception less than Equals parent class method throws an exception,
The subclass access permission is greater than or equal to the parent class method access.
2.
Java divides memory into two types, called stack memory, which is called heap memory.
Some basic types of variables and object reference variables defined in the function are allocated in the stack memory of the function. When a variable is defined in a block of code, Java allocates a memory space for the variable in the stack, and when the scope of the variable is exceeded, Java automatically frees the memory space allocated for that variable, which can be used immediately by another.
heap memory is used to hold objects and arrays created by new . The memory allocated in the heap is managed by the Java Virtual Machine automatic garbage collector. After creating an array or an object in the heap, you can also define a special variable in the stack that is equal to the array or the first address of the object in the heap memory, and this particular variable in the stack becomes the reference variable of the array or object. You can then use the reference variable in the stack memory in your program to access the array or object in the heap, which is the equivalent of an alias, or codename, of an array or object.
A reference variable is a normal variable that is defined when memory is allocated in the stack, and the reference variable is released in the program run to the extraterritorial scope. The array and object itself is allocated in the heap, and even if the program runs outside the block of code that uses the new generation of arrays and objects, the heap memory occupied by the array and the object itself is not freed, and arrays and objects become garbage when no reference variable points to it (such as the previous reference variable X=null). Can no longer be used, but still occupies memory and is released by the garbage collector at a later indeterminate time. This is also the main reason why the Java comparison occupies memory.
The above paragraphs come from a book of Java programming, in fact,The variables in the stack point to the variables in the heap memory, which is the pointer in Java。The sum up is that the object is stored in heap memory and the reference variable is stored in the stack memory. The stack memory points to the heap memory.
3.
For operational rate considerations, the Java compiler places frequently accessed variables into the cache (strictly the working memory) and reads the variables from the cache. In multithreaded programming, however, the values in memory and the values in the cache may appear inconsistent. Volatile is used to qualify variables to be read from memory only , guaranteeing that the values are consistent for all threads. But volatile does not guarantee atomicity, nor does it guarantee thread safety .
4.
Dynavalidatoractionform Dynamic Validation Form validation confirm the meaning
5.
Java Exercise 10.25