Java Program Structure : Few reasons for Java

Java Program Structure

Java Program Structure

Documentation section: The documentation section comprises a set of comment lines  giving the name of the program, the author and other details, which the programmer   would like to refer to at a later stage. Comments must explain why and what of classes  and how of algorithms. This would greatly help in maintaining the program. In addition to  the two styles of comments discussed earlier, Java also uses a third style of comment /** …. */ known as documentation comment. This form of comment is used for generating  documentation automatically.

Package Statement: The first statement allowed in a Java file is a package statement. This statement declares a package name and informs the compiler that the classes defined here belong to this package. Example:

Import Statements: The next thing after a package statement (but before any class definitions) may be a number of import statements. This is similar to the #include statement in C. Example: import student. test;This statement instructs the interpreter to load the test class contained in the package student. Using import statements, we can have access to classes that are part of other named packages.

Interface Statements: An interface is like a class but includes a group of method declarations. This is also an optional section and is used only when we wish to implement the multiple inheritance features in the program.

Class Definitions: A Java program may contain multiple class definitions. Classes are the primary and essential elements of a Java program. These classes are used to map the objects of real-world problems. The number of classes used depends on the complexity of the problem.

Main Method Class: Since every Java stand-alone program requires a main method as its starting point, this class is the essential part of a Java program. A simple Java program may contain only this part. The main method creates objects of various classes and establishes communications between them. On reaching the end of main, the program terminates and the control passes back to the operating system.

Few reasons for using Java

Java is a fun language. Let’s look at some of the reasons:

1. Built-in support for multithreading, socket communication, and memory management

(automatic garbage collection).

2. Object Oriented (OO).

3. Better portability than other languages across operating systems.

4. Supports Web based applications (Applet, Servlet, and JSP), distributed applications

(sockets, RMI. EJB etc) and network protocols (HTTP, JRMP etc) with the help of  extensive standardised APIs (Application Program Interfaces).

5. Robust, Portable, Architectural Neutral,Interpreted,Dynamic,Distributed,Secure

If you have any questions or suggestions kindly post it on Contact Us Form

Adarsh Patel

My Self Adarsh Suryakant Patel. Currently I am working as Assistant Professor at Parul Instiute of Engineering and Technology, MCA Department, Limda, Vadodara. Major Responsibility : * Lectures * Organizing Training and Expert Sessions for * Placement and Recruitment * Faculty Representative