Java Tutorial in javaglobe

  • In this tutorial , we can learn
    - What is Java technology
    - Why do we need it
    - What type of applications are created in java
    - Details of Java Technology

  • Introduction

  • Java is high level , secured and object-oriented programming language originally developed by Sun Microsystems .


    Features of Java

    • There are many features of java. They are also known as java buzzwords .So Java is
    • Simple
    • Object-Oriented
    • Platform independent
    • Secured
    • Robust
    • Architecture neutral
    • Portable
    • Dynamic
    • Interpreted
    • High Performance
    • Multithreaded
    • Distributed

    • First Java Program-"Hello World"

    • public class MyFirstJavaProgram 
       public static void main(String []args)
               System.out.println("Hello World");
      OUTPUT: Hello World

    • Let's look at how to save the file, compile and run the program. Please follow the steps given below:
      • Open notepad and add the code as above
      • Save the file as:
      • Open a command prompt window and go to the directory where you saved the class. Assume it's C:\
      • Type ' javac ' and press enter to compile your code. If there are no errors in your code, the command prompt will take you to the next line (Assumption: The path variable is set)
      • Now, type ' java MyFirstJavaProgram ' to run your program
      • You will be able to see ' Hello World ' printed on the window

    • Let's see what is the meaning of class, public, static, void, main, String[], System.out.println().

    • class keyword is used to declare a class in java
    • 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 core advantage of static method is that there is no need to create object to invoke the static method.
    • void is the return type of the method, it means it doesn't return any value
    • main represents startup of the program.It is declared as static.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
    • String[] args is used for command line argument. We will learn it later
    • System.out.println() is used print statement. We will learn about the internal working of System.out.println statement later

    • Internal Details of Hello Java Program:
    • In the previous page, we have learned about the first program, how to compile and how to 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.
    • What happens at compile time?

    • At compile time, java file is compiled by Java Compiler (It does not interact with OS) and converts the java code into bytecode.
    • What happens at runtime?

    • 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.

    • Basics or Fundamentals of Java:

    • 1) Identifiers
    • 2) Reserved Words
    • 3) Data Type
    • 4) Laterals
    • 5) Types Of Variables
    • 6) Arrays
    • 7) var-args methods
    • 8) Main methods
    • 9) Command Line arguments
    • 10) Java Coding Standards






    javaglobe adsense

    javaglobe adsense