Internal Details of Hello Java Program

In the previous section, we successfully created a “Hello Java” program and learned how to compile and execute it. Now, it’s time to delve deeper into the process of compiling and running a Java program. We’ll explore what goes on behind the scenes during these operations. Additionally, we’ll tackle some common questions related to the first program we created.

The Compilation Process in Java: What Occurs During Compile Time?

During the compile time of a Java program, the Java Compiler is responsible for the conversion of the Java code into bytecode. This process occurs independently of the operating system and is solely managed by the compiler.

Understanding Runtime in Java: What Happens During Program Execution?

During runtime, the following steps are performed:

Classloader: It is the subsystem of Java Virtual Machine that is used to load class files.

Bytecode Verifier: Checks the code fragments for illegal code that can violate access rights to objects.

Interpreter: Read bytecode stream then execute the instructions.

Q) Is it possible to save a Java source file with a name different from its class name?

Yes, if the class is not public we can save. It is explained in the figure given below:

To compile: javac Haard.java
To execute: java Simple

As we may have observed, in Java, it is possible to compile a program using a file name different from the class name, and then run the program using the class name instead. This indicates that it is indeed possible to save a Java source file with a name different from its class name.

Q) Is it permissible to include multiple classes within a single Java source file?

Yes, Including Multiple Classes in a Single Java Source File: An Example.

To gain a deeper understanding of the internal workings of a Java program, we recommend you to follow tutorials.freshersnow.com.