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.

0 comments:

Post a Comment

Advertisement

Find Us On Facebook

C Programming

More

C++ Tutorial

More

Java Tutorial

More

Computer Basics

More

MS Office

More

Database Management

More
Top