Java Program Structure

0
1235

In this topic, you will learn about, Java Program Structure.

A java program may contain one or more sections as shown below.

Structure Of Java Program

  1. Documentation Section: In this section comments are written. Comments include the name of the program, author of the program, date of the program, etc. Java also supports a special type of comment called documentation comment(/** …*/) other than a single line and multi-line comments.
  2. Package Statement: In this section, a new package is created. To create a package, a package statement is used.
  3. Import statement: In this section packages are imported. The package is a collection of classes and methods. To use any predefined function or a class, a related package is imported. For example, for doing input-output, import java.io.*; statement is used.
  4. Interface Statement: It is like a class but its variables are final and methods are abstract. In java, we cannot create a new class from two or more existing classes but we can create a new interface from two or more existing interfaces.
  5. Class Definition: Class can be defined as a user-defined data type that can hold data as well as functions. It is used to represent real-world objects.
  6. Main Method Class-As like C and C++, Java also used the main method. As we know that in java, we cannot create any things without a class. So unlike C++, main() method is also created in a class. The class contains the main method is called main() method class.

LEAVE A REPLY

Please enter your comment!
Please enter your name here