Oops with JAVA

Java is an purely object oriented language initially developed by Sun microsystems in 1991.Java is called purely object oriented language,because the main function resides inside the class, whereas C++ is called as partially object oriented language or middle level language.

Features of Java:

  •     Simple
  •     Secure
  •     Architecture neutral
  •     Platform independent
  •     Object oriented
  •     Robustness
  •     Dynamic

Conventions followed by JAVA:
     In java,name of the class in which the main function resides should be same as the file name and it is case-sensitive.
    There is no need of IDE to compile and run java programs.It is possible to compile and run a java program using Command prompt itself.But one can use certain IDE(Integrated Development Environment) to compile and run the java program.
Structure of java program:
    Packages, if required
    Class declaration
    Main function
Printing on the console screen:
       In java,to display some messages on console screen, System.out.println(); or System.out.print(); methods is used.
Example:
              System.out.println("Welcome");
              System.out.print("HI");
Sample java program:
Class Hello
{
         public static void main(String args[])
         {
                System.out.println("HELLO WORLD!!!!!!");
         }
}

                          The main function of JAVA is defined as static.The keyword static enables a programmer to call the function without using objects.
                          The java program can be typed in a notepad can be saved as "Filename.java".It can be compiled as javac Filename.java.To run the java program, java Filename command is used.
javac compiler:
                      The javac compiler is used to compile the java program.Once the java program is compiled,the byte code and class file is generated which can be used to run the java program under different platforms.

 
 

No comments:

Post a Comment