Answer:
Stack:
• Memory will be allocated at the compile time.
• Here the memory is allocated by the compiler.
• Memory will be allocated only in sequential locations.
• The memory will also be deleted by the compiler.
• There is lot of chance of memory wastage.
Heap:
• Memory will be allocated at the run time.
• Here the memory is allocated by the user.
• Memory will be allocated in sequential locations and non- sequential locations.
• The memory must be deleted explicitly by the user.
• There is no chance of memory wastage if the memory is handled perfectly.
Asked In: Many Interviews |
Alert Moderator