When the size of memory is less than the given value into the array then Out Of Memory Exception occurs which shows that heap size is full and if the java stack is full then exception stack-over-flow occur which shows that the calling of methods goes into the java stack.