In the previous page, we have learnt about the first program, how to compile and 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.
At compile time, java file is compiled by Java Compiler (It does not interact with OS) and converts the java code into bytecode.
At runtime, following steps are performed:
|Classloader: is the subsystem of JVM that is used to load class files.|
|Bytecode Verifier: checks the code fragments for illegal code that can violate access right to objects.|
|Interpreter: read bytecode stream then execute the instructions.|
|Yes, if the class is not public. It is explained in the figure given below:|
|To compile:||javac Hard.java|
|To execute:||java Simple|
|Yes, like the figure given below illustrates:|