Compiling a C++ program involves taking the source code (.cpp, .c files) and converting them into an executable or library that can run on a specified platform.
This process can be divided into three key stages:
Pre-processing
Compilation
Linking
Java is a platform independent programming language. As part of Java Compilation process, first, the source file i.e. ‘.java’ file is passed through the compiler, which then encodes the source code into a machine independent code, known as Bytecode. The Bytecode or class files '.class' generated by the compiler are independent of the machine configuration or the OS, which allows them to be run on any system. The main class file (the class that contains the main method) is passed to the Java Virtual Machine (JVM).