Java Programming Elements and Their Purpose
Java Programming Elements and Their Purpose
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
1. Module
2. Package
3. Class
4. Variable
5. Method
6. Constructor
7. Block
8. Inner class
• 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
• 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:
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: