(Note : Before reading this post , please atleast have a glance at the previous post . Click here .)
Let's see
what is the meaning of class, public, static, void, main, String[],
System.out.println() that were used in our first Java Program.
- class keyword is used to declare a class in java. Click
here to know more about a class.
- public keyword is an access modifier which represents
visibility, it means it is visible to all.
- static is a keyword, if we declare any method as static,
it is known as static method. The main method is executed by the JVM, so
it doesn't require to create object to invoke the main method. So it saves
memory.
- void is the return type of the method, it means it
doesn't return any value.
- main represents that execution of the program will be
started from here.
- String[] args is used for command line argument. This concept
will be learnt in later posts.
- System.out.println() is used to print a statement .
- javac the tool for compiling the program file converting .java file into .class file .
What
Happens at Compile Time ?
Explanation :
At compile time when you use the "javac" command , the java
file (MyFirstJavaProgram.java) is
compiled by Java Compiler(javac) without any inquiry and converts that file into bytecode
(MyFirstJavaProgram.class) .
compiled by Java Compiler(javac) without any inquiry and converts that file into bytecode
(MyFirstJavaProgram.class) .
What
Happens at Run Time ?
After knowing how compiling of the program was done ,
now we will see what happened when the program started running .
Explanation:
Let' s see what
the terms class loader , bytecode verifier , interpreter . hardware means which
are used in the above diagram .
· Bytecode verifier acts as a sort of gatekeeper . It ensures that code passed to the Java interpreter is in a fit state to be executed.
· Interpreter translates the Java bytecode into the code that can be understood by the Operating System.
· Runtime compiles verified bytecode to native machine code.
· Hardware means the OS (Operating System) which executes the native machine code.
So we have learnt the terms involved in our first program of Hello World and understood what was happening when we compile and run the program .
Keep
Compiling !!
Dissecting the First Java Program You Created
Reviewed by shashank
on
09:54
Rating:
No comments: