Introduction to JAVA – Part 2

The JAVA Runtime Environment:-

  • In this, java source files are compiled in the sence that they are converted into a set of bytecodes from the text in which you write them.
  • The bytecodes are stored in a .class file.
  • At runtime the bytecodes that make up java software are loaded, checked and run in an interpreter.
  • In some java technology runtime environment, a portion of the verified bytecode is compiled to native machine code and executed directly on the hardware platform.
  • This enables the java software code to run close to the speed of C and C++ with small delay at a load time to enable the code to be compiled to the native machine code.

The Class Loader:-

  • The class loader loads all the .class file for the execution of a program and loads on the operating system means on the JVM.
  • Those file which are imported from network sources, class loader provides a security to them.
  • After all the classes are loaded memory layout is determined for the memory management.
  • Memory management occur at runtime and at runtime java interpreter adds a protection to an unauthorized access.

The Bytecode Verifier:-

  • Before the execution of the program it is checked for its correctness which tests the instruction sets, code fragments for illegal code, etc.
  • This is done by the bytecode verifier. It checks the error handing.
  • Files which are imported from the network sources those are always tested by the bytecode verifier.

Now we start with the simple java application.

Example:- demo.java

The demo application

public class demo

{

Public static void main(String args[])

{

Hello h = new hello();

Hello.greet();

}

}

Hello.java:-

public class hello

{

public void greet()

{

System.out.println(“Hi.”);

}

}

So from above program we will get the output:-

Hi.

  • From the class demo main function is written as

public static void main(String args[])

  • So the main function describes the following,

public:-

  • public is written before the main, because, we have to call this function from outside the class, because, it is called by the JVM.

static:-

  • static is written before the main, because, we have to call the main function without creating an object of that particular class.

void:-

  • void keyword indicates that th main method does not return any value. This is important, because, the java programming language performs careful type checking to confirm that the methods called return the type with which they were declared.

args[]:-

  • args[] is the reference to an array of an object of class String. And arg parameter contains the arguments typed on the command line.

System.out.println(“Hi”);

  • System:- System is the class which provides the functionality of input and output.
  • out: out is the object of ostream class and
  • println():println() is the function which is defined in that particular class. println() function appends newline at the end of string (by default).
  • print(): print() only prints the line on the screen.

For more reading about technology news in singapore and seo to online marketing do view more about other pages.

Sourabh Bhunje

Sourabh Bhunje, B.E. IT from Pune University. Currently Working at Techliebe. Professional Skills: Programming - Software & Mobile, Web & Graphic Design, Localization, Content Writing, Sub-Titling etc. http://techliebe.com/about-us

Leave a Reply