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.
Object-Oriented Paradigm
🔹 Definition:
The Object-Oriented Paradigm (OOP) is a programming approach that models real-world
entities as objects. It focuses on data (objects) and the methods (functions) that operate on
that data, rather than procedural logic.
🔹 Characteristics:
Programs are built using classes and objects.
Focuses on real-world modeling and reusability.
Supports concepts like inheritance, encapsulation, polymorphism, and
abstraction.
Basic Concepts of Object-Oriented Programming
1. ✅ Class
A class is a blueprint for creating objects.
It defines attributes (fields) and methods (behaviors).
2. ✅ Object
An object is an instance of a class.
It contains real data and can perform actions defined by its class.
3. ✅ Encapsulation
Wrapping of data and methods into a single unit (class).
Protects internal state using access modifiers (private, public, etc.).
Accessed via getter and setter methods.
4. ✅ Inheritance
One class (child) inherits properties and methods of another (parent).
Promotes code reuse and hierarchical classification.
5. ✅ Polymorphism
Ability of methods to perform different tasks depending on the context.
Two types:
o Compile-time (Method Overloading)
o Run-time (Method Overriding)
6. ✅ Abstraction
Hides complex implementation details, showing only essential features.
Achieved through abstract classes and interfaces.
Benefits of Object-Oriented Programming
🔹 1. Modularity
Code is divided into separate classes (modules).
Each class handles one task or feature, making it easier to manage.
🔹 2. Reusability
Classes can be reused across different projects.
Inheritance allows extending existing functionality without rewriting code.
🔹 3. Maintainability
Encapsulated classes reduce the risk of unintended changes.
Easier to debug, modify, and enhance code.
🔹 4. Scalability:OOP supports building large-scale applications by organizing code into
manageable components.
🔹 5. Real-World Modeling:Maps real-world entities to code naturally using classes and
objects.
🔹 6. Security:Data hiding using encapsulation prevents unauthorized access and tampering.
🔹 7. Flexibility through Polymorphism:Code can work with objects of different
types through a single interface.
🔹 8. Improved Collaboration:Teams can work on independent classes/modules,
speeding up development.
Object-Oriented Programming (OOP) – Applications
🔹 What is OOP?
OOP (Object-Oriented Programming) is a programming methodology based on the concept
of "objects", which encapsulate data and behavior together.
🔹 Applications of OOP:
1. Real-world Systems Simulation
o OOP is ideal for simulating real-world systems like banking, airlines, or
medical systems.
2. Graphical User Interfaces (GUIs)
o Used in building GUI-based applications with components like buttons,
menus, etc., using languages like Java Swing or JavaFX.
3. Game Development
o Helps model game elements (players, enemies, items) as objects. Increases
modularity and reusability.
4. Web-Based Applications
o Backend frameworks (e.g., Java with Spring) use OOP principles for
structuring large-scale web apps.
5. Mobile Applications
o OOP is widely used in mobile app development, especially in Android
(Java/Kotlin).
6. Distributed Systems
o Objects can represent remote services or data models in distributed
architecture.
7. Software Engineering Tools
o Development environments, editors, debuggers, and modeling tools often
follow OOP design.
8. Database Management Systems
o OOP supports complex data models using object-relational mapping (ORM)
frameworks like Hibernate.
Java Evolution: History
🔹 Early History
1. Java was developed by Sun Microsystems in 1991 by a team led by James Gosling.
2. Initially named Oak, after an oak tree outside Gosling’s office.
3. Renamed to Java in 1995 because "Oak" was already a trademarked name.
🔹 Purpose of Creation
4. Designed for embedded systems in consumer electronics like TVs, remote controls,
etc.
5. Later shifted focus to internet-based applications due to Java’s platform-
independent features.
🔹 Java Milestones
6. 1995: Java 1.0 released – "Write Once, Run Anywhere" concept introduced.
7. 1998: Java 2 (J2SE) introduced, splitting Java into:
o Java SE (Standard Edition)
o Java EE (Enterprise Edition)
o Java ME (Micro Edition)
8. 2006: Sun open-sourced Java under the GNU General Public License (GPL).
9. 2010: Oracle Corporation acquired Sun Microsystems and took over Java
development.
10. Recent versions:
o Java uses a 6-month release cycle since Java 9.
o Latest stable version: Java SE 23 (as of 2025).
Highlighted Important Points (Quick Revision)
🌟 Applications of OOP:
Used in GUI, game development, web & mobile apps.
Ideal for systems modeling and distributed computing.
Improves code organization and real-world mapping.
🌟 Java History – Key Milestones:
1991 – Developed by James Gosling, named Oak.
1995 – Released as Java by Sun Microsystems.
1998 – Introduction of Java SE, EE, ME.
2010 – Oracle acquires Java.
Now – Follows regular 6-month release cycles.
Features of Java
Simple: Easy to learn with a clean syntax, similar to C/C++ but without complex
features like pointers.
Object-Oriented: Everything is based on objects and classes.
Platform Independent: Java code compiles into bytecode that runs on any system
with JVM (Java Virtual Machine).
Secure: Java programs run inside a secure sandbox with runtime checks and public-
key encryption.
Robust: Strong memory management with automatic garbage collection and
exception handling.
Multithreaded: Supports multiple threads to run concurrently, enabling better CPU
utilization.
Architecture-Neutral: Bytecode is not tied to any specific machine architecture.
Portable: Java applications can run on any platform without recompilation.
Interpreted and High Performance: Bytecode is interpreted or Just-In-Time
compiled by JVM for speed.
Distributed: Java supports networking capabilities like sockets and Remote Method
Invocation (RMI).
Dynamic: Classes can be loaded dynamically at runtime, supporting evolving
applications.
How Java Differs from C and C++
Feature Java C C++
Platform-
Platform Platform-dependent (machine Platform-
independent
Dependency code) dependent
via JVM
Memory Automatic garbage Manual memory Manual memory
Management collection management management
Pointers No pointers for safety Uses pointers extensively Uses pointers
Does not support multiple
Multiple Supports multiple Supports
inheritance of classes
Inheritance inheritance multiple inheritance
(uses interfaces instead)
Compiles to bytecode, Compiles to Compiles to
Compilation
nterpreted by JVM machine code machine code
Exception Built-in exception Limited support, mostly Supports exception
Handling handling error codes handling
Security Strong security features No built-in security No built-in security
Use Web, mobile, System programming, System programming, games,
Cases enterprise apps embedded systems real-time apps
Java and the Internet
Java is designed with the Internet in mind; it supports building distributed
applications.
Java applets allowed running Java programs inside web browsers (now mostly
deprecated).
Java programs can communicate over networks using TCP/IP sockets, RMI, and
other networking APIs.
Java provides security features essential for internet applications.
The Write Once, Run Anywhere philosophy makes Java ideal for internet apps that
run on multiple devices.
Java and the World Wide Web (WWW)
Java programs can be embedded in web pages as applets (small Java programs
running in a browser sandbox).
Applets provide interactive web content but have largely been replaced by newer
technologies (HTML5, JavaScript).
Java Servlet and JSP (Java Server Pages) technologies enable server-side
programming for dynamic web content.
Java Enterprise Edition (Java EE) offers APIs and runtime environments to build
scalable web applications.
Java’s robustness and security make it popular for web-based enterprise applications.
Web Browsers
Web browsers are software applications used to access and display web content
from the WWW.
Browsers like Chrome, Firefox, Safari, and Edge interpret HTML, CSS, and
JavaScript to render web pages.
Historically, browsers supported Java applets using a Java plugin to run Java code
inside the browser.
Due to security and compatibility issues, Java applet support in browsers has been
discontinued.
Modern web applications use JavaScript frameworks and server-side Java
technologies instead.
✅ Highlighted Important Points
Java’s platform independence is due to JVM running bytecode on any device.
Java removes complexity like pointers present in C/C++ for security and simplicity.
Java offers automatic memory management unlike manual management in C/C++.
Java supports network programming and distributed computing essential for
Internet applications.
Java applets were used to run Java programs on browsers, but now replaced by
modern web tech.
Web browsers no longer support Java applets due to security concerns.
Java EE and servlets enable server-side web programming for dynamic content.
Overview of java
Java program structure
A typical Java program consists of the following parts:
Class Declaration
Every Java program must have at least one class.
The class name should be the same as the filename.
Syntax:
public class ClassName {
// class body
2.Main Method
The entry point of the program where execution starts.
Syntax:
public static void main(String[] args) {
// statements
public: accessible by JVM
static: can be called without creating an object
void: does not return any value
String[] args: command-line arguments
3. Statements
Instructions inside the main method that perform actions.
Each statement ends with a semicolon ;.
Example statements:
int a = 5;
System.out.println("Value of a is: " + a);
Curly Braces {}
Define the start and end of classes, methods, and blocks of code.
Comments
Used for documentation, ignored by compiler.
// Single line comment
/* Multi-line comment */
Example:
public class HelloWorld { // Class Declaration
public static void main(String[] args) { // Main Method
System.out.println("Hello, World!"); // Statement to print text
Summary:
Java programs are organized into classes.
Execution starts from the main() method.
Statements inside main() perform tasks.
Curly braces group code blocks.
Comments are for explanations.
What are Java Tokens?
Tokens are the smallest elements in a Java program. The Java compiler uses tokens
to understand the code.
Types of Tokens
Token Type Description Example from program
Keywords Reserved words with special meaning public, class, static, void, int
Identifiers Names of variables, methods, classes HelloWorld, main, args, num
Literals Fixed values assigned to variables or used directly "Hello", 10, true
Operators Symbols for operations =, +, -, *
Separators Symbols that separate code {}, (), ;, ,
Comments Explanatory text ignored by compiler // This is a comment