0% found this document useful (0 votes)
12 views2 pages

Structure of Java Program

The document outlines the structure of a Java program, detailing the optional documentation section, package declaration, import statements, interface section, and class definition. It describes how to include comments, declare packages, import classes, create interfaces, and define classes with variables. Each section is explained with examples to illustrate the concepts clearly.

Uploaded by

swatisingh09.in
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views2 pages

Structure of Java Program

The document outlines the structure of a Java program, detailing the optional documentation section, package declaration, import statements, interface section, and class definition. It describes how to include comments, declare packages, import classes, create interfaces, and define classes with variables. Each section is explained with examples to illustrate the concepts clearly.

Uploaded by

swatisingh09.in
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

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.
o Single-line Comment: It starts with a pair of forwarding slash (//).
For example:

//First Java Program

o Multi-line Comment: It starts with a /* and ends with */. We write


between these two symbols. For example:
o /*It is an example of
multiline comment*/

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.
package javatpoint; //where javatpoint is the package name
package [Link]; //where com is the root directory and javatpoint
is the subdirectory

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. The import statement
represents the class stored in the other package. We use the import keyword to import
the class.
import [Link];
import [Link].*; /

Interface Section:-

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


the interface keyword to create an interface. An interface is a slightly different from the
class. It contains only constants and method declarations.

interface car
{
void start();
void stop();
}

Class Definition:-
class Student //class definition
{
}
class Student //class definition
{
String sname; //variable
int id;
double percentage;
}

You might also like