Advertisements
Advertisements
Question
What is the difference between static and dynamic allocation?
Distinguish Between
Advertisements
Solution
| Static Allocation | Dynamic Allocation |
| Memory is allocated at compile time. | Memory is allocated at runtime. |
| The size of memory is fixed and cannot be changed during execution. | The size of memory can be changed during execution as required. |
| It is faster but less flexible. | It is more flexible but may be slower. |
| Example: Normal array declaration int a[10]; | Example: Dynamic memory allocation using objects in Java like new int[10]; |
shaalaa.com
Is there an error in this question or solution?
Chapter 7: Arrays - One Dimension - Exercises [Page 174]
