Cognizant interview question

When we will use heap? some Database query what is pointer what is a dangling pointer Describe exceptions in java