You are on page 1of 7

Java Programming Elements and Their Purpose

Softwares required to develop, compile and execute a Java Program:


1. Editor Software: to write our Java program
2. JDK Software: to compile, JDK has a Compiler and to execute JDK has JVM.
3. Command Prompt Software: JDK gives only Compiler and JVM software. But to run
compiler and JVM software, we need Command Prompt Software.

Note: API means Libraries i.e., predefined programs given by SUN Microsystems. In C and
C++, we use the term Libraries. But in Java, we use the term API to refer to predefined
Libraries.
API → Application Programming Interface.
Java Programming Elements and Their Purpose

Java supports 8 programming elements:

1. Module
2. Package
3. Class
4. Variable
5. Method
6. Constructor
7. Block
8. Inner class

• Java is an Object-Oriented Programming Language. The main purpose of Object-


Oriented Programming Language is to automate Business Applications.
• To automate business applications, we have to perform the following operations:
o Deposit
o Withdraw
o Current Balance
o Transfer Money
o Etc.,
• Business Applications involve Money Transactions.
• We are performing the operations for the Customer i.e., the Object. That is, we are
performing operations for the Object.
• Object is a real-world thing.
• To develop the above operations, first we should decide for which object we are
performing these operations.
• Second, To bring real-world objects into the programming world, we should know
the characteristics of the Object.
• For example, the Customer has its own values and operations. The manager has its
own values and operations. The laptop has its own values and operations. One
object's values and operations must be grouped and differentiated from another
object’s values and operations.
• So, creating/developing a program around OOP involves:
o Identifying the different objects, the application has.
o Each object values and operations
to create as a group by separating from another object.

This is the style of developing applications using Object Oriented Programming


Paradigm.

• The programming elements are used to group values and operations into one
customer group. To represent this type/Object, we have Class.
• Java supports all the above programming elements for representing real-world
objects in the programming world and for implementing Object Oriented
Programming concepts using Java.
• According to OO programming, we must develop all programs around objects.
• An object is a real-world thing that you can see and use. For ex: Person, Vehicle,
Mobile, Bank Account, etc., are objects.
• Developing a program around an object means we must create a program

1. to represent a particular object. Ex: Person


2. by storing that object values. Ex: name, height, weight,...

by using a class, variable, and methods respectively.

• class is meant to represent an object.

variable is meant to represent value.

method meant for representing the operation.

• Hence by using the above programming elements, we must bring the real world to
perform their operations by using computer as part of one business application.
• As per the above diagram, we must create 6 classes:

• Basically, by using class, we are binding properties and operations of an object as


one group by separating from other object’s properties and operations as shown in
the above programs.
• As per the above diagram, we can conclude that

1. We must create multiple classes as many different types of objects as


we want to create.
2. In each class, we must create multiple variables based on the multiple
values of the object we want to store.
3. Also, inside the class, we must create multiple methods based on the
multiple operations this object performs.

For example, as per the above diagram, we must create 6 classes with the required
number of variables and methods.
• Major programming elements:
o Class
o Variable
o Method
Class:
A Class is a blueprint/design document of objects. It is used for representing real-
world objects in the programming world.
Variable:
A variable is a named memory location.
Constructor/Block:
Constructor/Block is used to initialize/store values in memory. This process of storing
values in memory is called Initialization.
Method:
After storing values, we perform operations by reading those values. We write the
operation logic inside the Method.
Java Program Structure:

Purpose of each Programming element:


Module: meant for grouping packages
Package: meant for grouping classes
Class: meant for representing an object by grouping variables, blocks, constructors,
methods and inner class
Variable: meant for representing value by allocating memory
Block/constructor: meant for storing values in variables
Method: means for representing operations
Inner Class: meant for representing an inner object of an outer object.

You might also like