What is a Compilation Unit

A compilation unit is a Java source code file.

In the context of Core Java, a compilation unit refers to a source code file. It is the basic unit of compilation, typically containing a single Java class. A compilation unit can also include interface definitions, enumeration definitions, and annotation types. The Java compiler processes each compilation unit separately, generating corresponding bytecode files (.class files) for further execution on the Java Virtual Machine (JVM).