Wednesday, 27 May 2015

Structure of java program

A java programs may contains many classes. Classes contain data methods that operate on the data members of the class. A java program may contain one or more sections as given below.

Documentation Section:

It comprises a set of  comment kines giving the name of the program, the author and other details with programmer would like to refer to at a later stage.

          Java uses the comments style as /**..........*/ known as documentation comments.

Package statements 

                     The first statement allowed in java file is a package statement. This statement declares a package name and informs the compiler that the class defined here belong to this package.

                Example: package myPackage;

Import statement 

                    This is similar to #include statement in C. Just like #include it can also used to link all the resources that are need to run your java program. For example the following statement

                             import java.Scanner

This statement instruct the interpreter to load the Scanner class contained in the package java.util.

Interface statements 

                           An interface is like a class but includes a group of method declarations. This is optional section.

class definitions

                                  A java program may contain multiple class definitions. class are the primary and essential elements of a java program.

Main method class

                     The main method creates objects of various classes and established communications between them. on reaching the end of main, the program terminates and the control passes back to the operating system.


Post a Comment

Note: only a member of this blog may post a comment.

Find Us On Facebook

python tutorial


C Programming


Java Tutorial


Data Structures


MS Office


Database Management