Explain The Structure Of Java Program?

Java program may contain may classes of which only one class defines a main method.
Classes contain data members (of the class) and methods that operate on the data members of the class.

A java program may contain one or more sections.

java structure


Document Section :

Document section is a set of comment lines giving the name of the program, the author name and other details.

Comments must explain why and what of classes and how of algorithms.

We have two types of comments.

1) //single line comments        
2) /* …. */ multiple line comments.

Package Statement :

The first statement allowed in a Java file is a package statement.
This statement declares a package name and informs the compiler that the classes defined here belong to this package.

Ex : Package Student ;

Import Statement :

The next thing after a package statement may be a number of import statement.
This is similar to # include statement in C import java. io. * ;

Interface Statements :

An interface is like a class but includes a group of method declarations. This is also an optional section and is used only when we wish to implement the multiple inheritance.

Class definitions :

 A Java program may contain multiple class definitions.
Classes are primary and essential elements of a Java program.

Main method class:

Since every Java alone program require a main method as starting point.
A simple Java program may contain only this part.

The main method creates objects of various classes and establish, communication between them.

class sample.
{
  public static void main (String args [ ])
{
    System out printer (“hai every one”) :
}
}


Related

Java 3857521123712237666

Post a Comment

emo-but-icon
:noprob:
:smile:
:shy:
:trope:
:sneered:
:happy:
:escort:
:rapt:
:love:
:heart:
:angry:
:hate:
:sad:
:sigh:
:disappointed:
:cry:
:fear:
:surprise:
:unbelieve:
:shit:
:like:
:dislike:
:clap:
:cuff:
:fist:
:ok:
:file:
:link:
:place:
:contact:

item