Structure of the Java Program – Java Tutorial

Structure of the Java Program – Java Tutorial

Structure of the Java Program - Java Tutorial

Problem Statement

Explain the structure of the Java program with an example.

OR

Write a short note on the structure of the Java Program with an example. 

Solution:

The structure Java program contains mainly five sections.

  1. Documentation Section
  2. Package Statement Section
  3. Import Statement Section
  4. Class Definition Section
  5. Main Method Class Section
Structure of the Java Program

1. Documentation section:

The documentation section provides information about the source program. This section contains information that is not compiled by Java. Everything written in this section is written as a comment.

2. Package statement section:

It consists of the name of the package by using the keyword package. When we use the classes from this package in our program then it is necessary to write the package statement at the beginning of the program.

3. Import statement section:

All the required java API can be imported by the import statement. There are some core packages present in java. These packages include the classes and methods required for java programming. These packages can be imported into the program in order to use the classes and methods of the program.

4. Class definition section:

The class definition section contains the definition of the class. This class normally contains the data and the methods of manipulating the data.

5. Main method class:

This is called the main method class because it contains the main() function. This class can access the methods defined in other classes.

Sample Java Program

/*  This is my first Java Program */
import java.io.*;
class FirstProgram
{
	public static void main(String args[])
	{
		System.out.println(“Welcome to Java Programming”);
	}
}

Summary:

In this article, we understood the Structure of the Java Program – Java Tutorial. If you like the tutorial share it with your friends. Like the Facebook page for regular updates and the YouTube channel for video tutorials.

Leave a Comment