In order to better perform in Garbage collection questions in any Java interview, It’s important to have a basic understanding of Java Heap space.
Heap is divided into different generations e.g. new generation, old generation, and PermGen space.PermGen space is used to store class’s metadata and filling of PermGen space can cause java.lang.OutOfMemory: PermGen space. It's also worth noting to remember the JVM option to configure PermGen space in Java.