Object-Oriented Paradigm – Basic Concepts of Object-Oriented Programming –
Benefits of Object-
Oriented Programming –Application of Object-Oriented Programming. Java
Evolution: History –
Features – How Java differs from C and C++ – Java and Internet – Java and www
–Web Browsers.
Overview of Java: simple Java program – Structure – Java Tokens – Statements –
Java Virtual
Machine.
Java is a:
High-level
Object-Oriented
Platform-Independent
General-purpose Programming Language
✅ Developed by: James Gosling at Sun Microsystems in 1995
✅ Owned by: Oracle Corporation
✅ Java programs run on the Java Virtual Machine (JVM)
“Write Once, Run Anywhere” — Java code runs on any system with JVM.
(Platform-Independent)
Java Virtual Machine (JVM)
The Java Virtual Machine (JVM) is an abstract engine or virtual computer that enables Java
programs to run on any device or operating system.
Purpose of JVM
Executes Java bytecode (compiled .class files)
Converts bytecode into machine code specific to the host OS and CPU
Manages memory, threads, security, and exception handling
Java Code Compilation Flow:
Java Source Code (.java)
Java Compiler (javac)
Bytecode (.class)
JVM executes bytecode on any platform
JVM is the heart of Java’s platform independence. Converts platform-independent
bytecode into platform-specific [Link] memory, execution, security, and
performance optimizations. Works with JDK and JRE to provide a complete Java
development and runtime environment.
Major Responsibilities of JVM
Task Description
Class Loader Loads .class files (bytecode) into memory
Ensures code safety and structure (no memory access
Bytecode Verifier
violations)
Interpreter / JIT Compiler Converts bytecode to machine code for execution
Memory Management Handles allocation/deallocation via Garbage Collector
Runtime Stack
Maintains method calls, local variables, and operands
Management
Exception Handling Manages exceptions during execution
Security Manager Applies access rules and sandboxing
JVM vs JRE vs JDK
Component Description
JVM (Java Virtual Machine) Runs the Java bytecode
JRE (Java Runtime Environment) Contains JVM + libraries to run Java apps
JDK (Java Development Kit) Contains JRE + development tools like javac, javadoc
JVM Architecture (Diagram Description)
1. Class Loader Subsystem
Loads, links, and initializes classes.
Sub-components:
o Bootstrap ClassLoader
o Extension ClassLoader
o Application ClassLoader
2. Runtime Data Areas
Method Area: Stores class metadata, method info, static variables.
Heap: Stores all objects and instance variables.
Java Stack: Stores stack frames (local variables, method calls).
Program Counter (PC) Register: Tracks next instruction.
Native Method Stack: Supports native (non-Java) code execution.
3. Execution Engine
Interpreter: Executes bytecode instructions one by one.
Just-In-Time (JIT) Compiler: Improves performance by compiling frequently used
code to native machine code.
4. Native Interface
Allows JVM to interact with native libraries (written in C/C++).
5. Garbage Collector
Automatically frees memory occupied by unreferenced objects.
[Link]-Oriented
Java is a fully object-oriented programming language, where
everything is organized using classes and objects. It supports
encapsulation, inheritance, polymorphism, and abstraction,
making it ideal for modular and reusable code.
2. ✅ Platform Independent
Java achieves platform independence through its use of bytecode.
Java source code is compiled into bytecode, which can run on any
operating system using the Java Virtual Machine (JVM) —
enabling the principle of "Write Once, Run Anywhere."
Simple
Java is designed to be easy to learn. It has a clean and readable
syntax similar to C/C++, but avoids complex features like pointers
and manual memory management. Java also includes automatic
garbage collection, simplifying development.
4. ✅ Secure
Java offers a highly secure execution environment. It runs code
within a sandbox, preventing unauthorized access to system
resources. Security features include bytecode verification, access
controls, and public-key encryption.
5. ✅ Architecture-Neutral
Java bytecode is architecture-neutral, meaning it is not tied to any
specific CPU or hardware platform. This ensures consistent behavior
of Java programs across all platforms with a JVM.
6. ✅ Portable
Because of its architecture neutrality and platform independence,
Java is highly portable. Java programs can be moved from one
system to another without modification or recompilation, as long as
the target system has a JVM.
Object-Oriented Paradigm
What is Object-Oriented Programming (OOP)?
Object-Oriented Programming (OOP) is a programming paradigm based on the concept of
objects, which are instances of classes. It organizes code into reusable units (classes) that
bundle data (attributes) and behavior (methods) together.
Java is a pure object-oriented language ,( No, Java is not a 100% pure object-oriented
language.
except for primitive data types), meaning almost everything in Java is represented as objects.
Object-Oriented Paradigm in Java
1. Object-Oriented Programming (OOP) is a programming model organized around
objects rather than actions or logic.
2. Java is an object-oriented language that models real-world entities using classes
and objects.
Class
A class is a user-defined data type that acts as a blueprint for creating objects.
It contains fields (variables) and methods (functions) that define the behavior of the
object.
Classes support encapsulation by grouping related data and methods.
A class defines the state and behavior that the objects created from it will [Link]
uses the class keyword to define a class.
Classes can contain constructors, which are special methods used to initialize
objects.
Classes can implement interfaces or extend other classes (inheritance).
A class is a blueprint or template for creating objects.
objects
An object is an instance of a class containing data (fields) and behavior (methods).
3. Encapsulation is the practice of hiding internal details and exposing functionality
through public methods.
4. Inheritance allows a class to acquire properties and behaviour from another class,
promoting code reuse.
5. Polymorphism enables a single interface or method to operate in multiple forms,
improving flexibility.
6. Abstraction hides complex implementation details and shows only the essential
features of an object.
7. Java supports modular:
Modularity means dividing a program into independent modules (classes/objects).
Each module handles a specific functionality of the application.
Improves readability and maintainability.
Easier to test and debug modular applications.
Promotes reusability — modules can be used in multiple projects.
Supports team collaboration, as different developers can work on different
modules.
Allows loose coupling and high cohesion, which are good design principles.
8. maintainable,
Maintainable code is easy to understand, debug, and [Link]’s separation of
concerns improves [Link] prevents unexpected modifications
of [Link] and abstraction reduce code duplication. Modular design
allows isolated changes without affecting the entire application. Easier to fix bugs or
extend functionality. Reduces long-term maintenance costs.
reusable code through its object-oriented structure.
Reusability allows code to be used again in different parts of the application or in other
[Link] and interfaces are main tools for reusability in [Link]
development time and effort. Reduces chances of introducing bugs — reused code is often
[Link] create libraries and frameworks that can be shared across projects.
Encourages consistency in design and [Link]’s package system helps organize
reusable components efficiently.
9. OOP in Java helps in organizing complex programs, making them easier to
understand and manage.