0% found this document useful (0 votes)
99 views11 pages

Smart Programming: Java Program Structure & Explanation

The document provides a structured guide to preparing and understanding a Java program, detailing steps such as downloading necessary software, creating the program, and compiling it. It outlines the main sections of a Java program, including documentation, package statements, import statements, class/interface sections, and the main class section. Additionally, it includes information on Java naming conventions and offers resources for further learning through company links and contacts.

Uploaded by

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

Smart Programming: Java Program Structure & Explanation

The document provides a structured guide to preparing and understanding a Java program, detailing steps such as downloading necessary software, creating the program, and compiling it. It outlines the main sections of a Java program, including documentation, package statements, import statements, class/interface sections, and the main class section. Additionally, it includes information on Java naming conventions and offers resources for further learning through company links and contacts.

Uploaded by

rs9154040
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Smart Programming : Channel

An investment in Knowledge pays the best interest….

Java Program Structure


& Explanation
Smart Programming (Mohali, Chandigarh India)
Call or Whats App Online & Industrial Training: +91 62838-30308

=> Steps to prepare Java First Program :-


1. Download & Install Java Softwares
(JDK, Editor, IDE's)
2. Create Java First Program
2.1 Java Naming Conventions
2.2 Structure of Java Program
2.3 Java Program Explanation
3. Compile & Run Java Program

=> Structure Of Java Program :-


-> There are 5 main sections in a java program:-
1. Documentation Section
2. Package Statement
3. Import Statement

1
Smart Programming (Mohali, Chandigarh India)
Call or Whats App Online & Industrial Training: +91 62838-30308

4. Interface/Class Section
-> Variables & Methods
5. Main Class Section
-> main method

1. Documentation Section :-
-> It contains the basic information about java
program for eg. author's name, date of creation,
version, program name, company name, client
name, description etc
-> This part is OPTIONAL
-> To create documentation section we use
comments
-> There are 3 types of comments :-
1. Single Line Comment (//)
2. Multi-Line Comment (/* ----- */)

2
Smart Programming (Mohali, Chandigarh India)
Call or Whats App Online & Industrial Training: +91 62838-30308

3. Documentation Comment (/**-*-*-*-*-*/)


-> To provide description or metadata of the
program Java introduced new feature in JDK 1.5
version i.e. "Annotation" (@---)
-> If we use comments for documentation
section then at compilation phase these comments
will be removed by the compiler which cannot be
read further, so to resolve this problem java
introduced annotation which cannot be removed at
compilation or runtime.
-> If you want to provide documentation section
in html form, then we can use following command in
CMD :-
javadoc FileName.java

-> javap -version (to get JDK version)


-> javap packagename.ClassName (to get the
class details)

3
Smart Programming (Mohali, Chandigarh India)
Call or Whats App Online & Industrial Training: +91 62838-30308

2. Package Statement :-
-> It is a group of similar type of classes or
interfaces or packages
-> Advantage of package :-
1. It prevents naming conflicts of classes or
interfaces
2. Easy to maintain
3. Accessability to classes or interfaces can
be controlled (Security)
4. Reusability
-> Types of packages :-
1. Predefined Package (which are already
created by java for eg. lang, awt, swing, util, sql etc)
2. User Defined Package (which are created
by the developer)
-> Syntax : package package_name;
-> Example :-
package techdept.aa.bb;
4
Smart Programming (Mohali, Chandigarh India)
Call or Whats App Online & Industrial Training: +91 62838-30308

class Employee
{

}
-> Conditions for package :-
1. Package statement should be only one in
the single java file
2. Package statement should be the first
statement in java file
-> Java provides one facility for naming
convention for package that is we can create
package on the same name of our domain name but
in reverse order. For eg.
com.smartprogramming.usajohn.techdept
com.smartprogramming.usajohn.managingdept
-> This is OPTIONAL but you should always put
all the classes or interfaces in any one package

5
Smart Programming (Mohali, Chandigarh India)
Call or Whats App Online & Industrial Training: +91 62838-30308

3. Import Statement :-
-> Import statements is used to make available
the classes or interfaces which we are going to use
in present java file
-> Syntax :
1. import
packagename.subpackagename.ClassName;
2. import packagename.*;
-> if we use "import packagename.*;" only
classes or interfaces will be imported, not the
subpackage.
-> If we dont want to use import statement then
we can directly write the packagename.ClassName
to use that class.
-> This is OPTIONAL to use but mainly we use it
in major level projects.
-> This line is written after the package line.
-> java.lang package is the only package which
is imported by default
6
Smart Programming (Mohali, Chandigarh India)
Call or Whats App Online & Industrial Training: +91 62838-30308

4. Interface/Class Section : -> Variables &


Methods
-> In this section we create classes or interfaces
which contains variables, methods, constructors,
blocks etc.

5. Main Class Section -> main method :


-> In every project or java file there should be
one main class which should contain main() method
from which the execution of the program will start.
-> Syntax :
class Test
{
public static void main(String[] args)
{

}
}
7
Smart Programming (Mohali, Chandigarh India)
Call or Whats App Online & Industrial Training: +91 62838-30308

=> Java Program Explanation :-


class Test
{
public static void main(Stirng[] args)
{
System.out.println("hello");
}
}

8
Smart Programming (Mohali, Chandigarh India)
Call or Whats App Online & Industrial Training: +91 62838-30308

Interview Questions :-
=> Explanation of each and every word in simple
java hello program

9
Smart Programming (Mohali, Chandigarh India)
Call or Whats App Online & Industrial Training: +91 62838-30308

Company Links & Contacts

Company Name: Smart Programming (+91 62838-30308)

Address : Chandigarh & Mohali (Punjab), India

Websites: https://www.smartprogramming.in/
https://courses.smartprogramming.in

Android App:
https://play.google.com/store/apps/details?id=com.sma
rtprogramming

YouTube Channel:
https://www.youtube.com/c/SmartProgramming

10

You might also like