Subclass of java.lang.Error which usually happens when our Java Virtual Machine runs out of memory is known as OutOfMemoryError in Java.