Structure of Java Program

 Structure of Java Program :-
























Documentation Section

The documentation section is an important section but optional for a Java program. It includes basic information about a Java program. The information includes the author's name, date of creation, version, program name, company name, and description of the program.

Package Declaration

The package declaration is optional. It is placed just after the documentation section. In this section, we declare the package name in which the class is placed.

Import Statements

The package contains the many predefined classes and interfaces. If we want to use any class of a particular package, we need to import that class.

Interface Section

It is an optional section. We can create an interface in this section if required.

Class Definition

In this section, we define the class. It is vital part of a Java program. Without the class, we cannot create any Java program.

Main Method Definition 

In this section, we define the main() method. It is essential for all Java programs. Because the execution of all Java programs starts from the main() method. In other words, it is an entry point of the class. It must be inside the class. Inside the main method, we create objects and call the methods. We use the following statement to define the main() method:



 

Post a Comment

0 Comments