Featured Post

Wednesday, May 10, 2017

sample program in java



class sample      /* program must be saved with name sample and with java extension*/
{
  public static void main(String args[])
   {
     System.out.println("this is my first program"); /* output statement in java*/
   }
}


D:\cjuschools>javac sample.java
D:\cjuschools>java sample
this is my first program


        /*key notes: java is a pure object oriented programming language*/
         /* main function must be defined inside class/*
         /* the name of the program must be the main function class name/*
         /* the above program must be saved with sample.java/*
         
          /* public is a access specifier/*
           /*static is a keywor specifying that there is only one main function/*
           /*void specifies no return/*
           /*main is a function which tells compiler start executing here*/
           /*System is class in the java.lang package/*
           /*out is a static member of the sytem class/*
           /*println is a method of PrintStream class*/


         

object oriented programming using java, sample,system.out.println,static,main,public, void,inheritance, scanner, io stream, polymorphism, interface,abstract class
         
         


No comments:

Post a Comment