Explain the process of memory allocation using new operator.
Answers
The new operator is used for the process of instantiation of objects in java.
To say in layman's terms, instantiation simply allocates the memory to the object.
And the process of memory allocation employed by the new operator is known as Dynamic Memory Allocation.
Dynamic memory allocation allows the program to be more memory efficient as the memory location is allocated only when the new operator is used and as soon as the data object is unreferenced (or in other words, is of no use any longer), the memory is freed for further allocation which is in contrary to its counterpart- Static Memory Allocation, in which the memory is allocated at the beginning and is kept reserved until the end of the program unless the manually freed takes place.
Explanation:
introduction to C++ language