First Java Program / Hello Program

Posted on

First Java Program / Whats up program

 class Whats up{

      public static void predominant(String args[]){

System.out.println(“Whats up”);

}

}

———————————————————————————————————— 

Output : Whats up

————————————————————————————————————

How to compile and run the java program

 Save this program as :  Whats up.java

To compile : javac Whats up.java

To run : java Whats up

 

Understanding the Whats up Program

 

class key phrase is used to declare a class in java.

public key phrase is an entry modifier which represents visibility, it means it is seen to all.

static is a key phrase, if we declare any technique as static, it is identified as static technique. The core benefit of static technique is that there is no want to create object to invoke the static technique. The predominant technique is executed by the JVM, so it doesn’t require to create object to invoke the predominant technique. So it saves reminiscence.

void is the return kind of the technique, it means it doesn’t return any worth.

predominant represents begin up of the program the program execution begins from the predominant() technique.

String[] args is used for command line argument.

System.out.println() is used print assertion. Right here it is used to print the “Whats up”.

 

Understanding Inside Particulars of Whats up program

 

At Compile time : javac Whats up.java 

Compile – In this step the programmer offers the javac command and the .java information are transformed into bytecode which is the language understood by the java digital machine (and this is what makes java platform impartial language) Any compile time errors are raised at this step

 

At run time :

Load – The program is then loaded into reminiscence. This is completed by the class loader which takes the .class information containing the bytecode and shops it in the reminiscence. The .class file can be loaded from your exhausting disk or from the community as properly.

Confirm – the bytecode verifier checks if the bytecode loaded are legitimate and do not breach java’s safety restrictions.

Execute – The JIT (Simply-in-Time) compiler compiles the program one bytecode at a time and runs the program.

 

Eg: Execution Command   java Whats up

  1. Begin JVM
  2. Create and Begin Most important Thread  (Most important Thread is accountable for checking if not discovered Runtime Exception will happen saying Exception in Thread Most important).
  3. Find Whats up.class file
  4. Load Whats up.class file
  5. Execute Most important technique
  6. Unload Whats up.class
  7. Terminate Most important Thread
  8. Shut down JVM