Friday, 30 October 2020

Simple Java program

 

 

Simple Java program 


Consider  a simple  java  program below :-



class FirstProgram 

{

   public static void main(String args[])

    {

      System.out.println ("This is my first program ");

 

    }

 

}

 

 

 

 

 

1. The  file must be named  " FirstProgram .java"  to equivalent the class name  containing  the main  method .

 

2.  Java  is case  sensitive. This  program  defines  a class  called "FirstProgram ".

 

3. A class  is an  object oriented  term .  It is  designed  to perform  a specific  task . A java  class  is  defined by  its  class name , an open  curly  brace, a list  of  methods  and  fields, and a close curly  brace.



4. The  name of  the  class  is mode  of  alphabetical  charecters and  digits  without  spaces,  the  first charecter must be alphabetical.

 

 

5.  The line public static void main(String args[]) shows where  the  program will  start  running .  The  world  main  means  that  this  is the main  method  and  the JVM  starts running  any  program  by  executing  this method first.

 

 

 6. The main method  in "FirstProgram.java" consists of  a single  statement  :

System.out.println ("This is my first program "); 


The  statement  outputs  the  character between  quotes to the console.

 

 

 

 

 

1 comment:

Student Marks Calculation app using java

      import javax.swing. *; import java.awt.event.ActionEvent ; import java.awt.event.ActionListener ; public class Student { private J...