Articles For Website

What is the Structure of Java Programming Language?

Java programming language is a platform-independent & a secure programming language. With a broad variety of applications, Java programming language or JPL has been in demand from the last few decades. The out-of-the-box features help java stand apart. Candidates can Join Techno Globe Institute for Best Java Training in Jaipur. Following is the structure of Java Programming:

 

 

Documentation Section

This section is used to improve the readability of the program. It consists of comments in Java which include basic information such as the method’s usage or functionality to make it easier for the programmer to understand it while reviewing or debugging the code. A Java comment is not necessarily limited to a confined space, it can appear anywhere in the code.

The compiler ignores these comments during the time of execution and is solely meant for improving the readability of the Java program.

There are 3 types of comments that Java supports

 

Package Statement

There is a provision in Java that permits you to declare your classes in a collection known as a package. There can be only one package statement in a Java program and it has to be at the beginning of the code before any class or interface declaration. This statement is optional, for instance, take a look at the statement below.

  1. package student;

This statement says that all the classes & interfaces defined in this source file are a part of the student’s package. And only a package can be declared in the source file.

 

Import Statement

Various pre-defined classes are stored in packages in Java, this statement is used to refer to the classes stored in other packages. This statement is always written after the package statement but it has to be before any class declaration.

We can import a particular class or classes in an import statement. Here is the following example to understand how to import statements works in Java.

 

Interface Section

This section is used to specify an interface in Java. It is an optional section which is mainly used to implement multiple inheritances in Java. An interface is very similar to a class in Java but it contains only constants and method declarations.

An interface cannot be incorporated but it can be implemented by classes or extended by other interfaces.

1 interface stack{

2 void push(int item);

3 void pop();

4 }

 

 Class Definition

A Java program may contain some class definitions, classes are an important part of any Java program. It describes the information about the user-defined classes in a program.

A class is a collection of variables & methods that operate on the fields. Each program in Java will have at least one class with the main method.

A Java program may contain some class definitions, classes are a significant piece of any Java program. It depicts the data about the client characterized classes in a program.

A class is an assortment of factors and techniques that work on the fields. Each program in Java will have in any event one class with the fundamental technique.

 

Main Method Class

The main method is from where the execution starts and follows the order specified for the following statements. Let’s take a look at a sample program to understand how it is structured.

 

Exit mobile version