Pergunta de entrevista da empresa WIT Software

What's the difference between the heap and the stack when allocating variables. When should one or the other be used?