Professional Documents
Culture Documents
Chapter 3
Chapter 3
Science
Chapter 3
Overview of Java
Language
Application Type
Stand alone Programs Programs
• COMPILE – The compiler here takes the ‘.java’ file, compiles the program
and then the byte code is generated and saved as ‘.class’ file.
• VERIFY – The JVM’s subpart called ‘Byte Code verifier’ checks the byte
code and confirms that all byte code are valid and do not violate Java’s
security restrictions.
• EXECUTE – The execution engine interprets the code line by line using the
Just In Time (JIT) compiler. The JIT compiler does the execution pretty fast.
class Simple{
public static void main(String args[]){
System.out.println("Hello Java");
}
}
• void is the return type of the method, it means it doesn't return any value.
class AddNumbers {
public static void main(String args[]) {
int x, y, z;
x = 10;
y = 10;
z = x + y;
System.out.println("Sum of integers = "+z);
}
}
class Computer {
Computer() {
System.out.println("Constructor of Computer class."); }
void computer_method()
{
System.out.println("Power gone! Shut down your PC soon...");
}
public static void main(String[] args) {
Computer.computer_method();
Laptop.laptop_method();
}
}
class Laptop {
Laptop() {
System.out.println("Constructor of Laptop class.");
}
void laptop_method() {
System.out.println("99% Battery available.");
Sheela D V - Department of Computer Science 8
}
Java Program Structure