Java Program Structure

In this tutorial you will learn about the Java Program Structure and its application with practical example.

Java Program Structure

In Java, like any other programming language we have a specification available for program structure, every java program is consist of following building blocks –

java-structure

 

Documentation Section :- Documentation section is generally meant include set of comments, that is used to provide the information about the program written like name of a program, utility of program, date of creation, date of last modification ,author name, licensing or copyrights information and any other information that programmer wish to put for the references.

Example:

Package Statement :- This is the section used for package declaration, the package statement declares a package name and notify the compiler that the classes defined here will belong to this package.

Example:-

Import Statements :- The import statements is used to import packages that contains all of the required classes, interfaces. java.lang.*; package is imported by default and this package is known as default package.

Example:-

Interface Statement :- An Interface is like a class that usually contains a group of method declarations. It’s an optional section and can be used when we want to implement multiple inheritance within a program.

Class Definition :- The classes are used to map real world entities into programming. The Classes are the key building block of any Java program. A java program may include several class definitions.

Recommended:-  Java Relational Operators

Main Method Class :- A java program may include multiple classes, but there can be only one class which will defines the main method.

Main Method Definition :- This is the most vital part of any each and every java program, it is mandatory for java program to have a class with main method definition. There can be only one class which will defines the main method. The Java program execution starts with main method. Java program can not be executed without the main method. The main method is responsible for the execution of all the user defined statement, functions and library functions. The main method further structured into – variable declaration, function declaration and user defined executable statements.

In this tutorial we have learn about the Java Program Structure and its application with practical example. I hope you will like this tutorial.