Program Internal

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

Internal Details of Java Program With Example

Internal Details of Hello Java

In the previous page, we have learned about the first program, how to compile and how to run the first java program. Here, we are going to learn, what happens while compiling and running the java program. Moreover, we will see some question based on the first program.

What happens at compile time?

At compile time, java file is compiled by Java Compiler (It does not interact with OS) and converts the java code into bytecode.

compilation of simple java program

What happens at runtime?

At runtime, following steps are performed:
what happens at runtime when simple java program runs

Class loader: is the subsystem of JVM that is used to load class files.

Byte code Verifier: checks the code fragments for illegal code that can violate access right to objects.

Interpreter: read byte code stream then execute the instructions.


Q) Can you save a java source file by other name than the class name?

Yes, if the class is not public. It is explained in the figure given below:
how to save simple java program by another name


To compile:


To execute:

java Simple


Q) Can you have multiple classes in a java source file?

Yes, like the figure given below illustrates:
how to contain multiple class in simple java program