Corrected Report English
Corrected Report English
Table of Contents
OBJECT-ORIENTED PROGRAMMING with JAVA 2
Abstract
This report explores in depth the fundamental concepts of Object-Oriented Programming
(OOP) and their specific application within the Java language, a pillar of modern software
development. The main objective is to provide a clear and structured understanding of key
principles such as encapsulation, inheritance, polymorphism, and abstraction, illustrating each
with detailed explanations and concrete Java code examples. The document examines how
these concepts build robust, modular and maintainable applications. It also looks at how Java
implements these paradigms, highlighting specific mechanisms such as classes, objects,
interfaces, and access modifiers. In conclusion, the report summarizes the importance of OOP
in Java for creating efficient, scalable software solutions, highlighting the significant
advantages in terms of code reusability, flexibility, and complexity management in large-scale
projects. This work is intended to serve as a reference for students and developers seeking to
master the theoretical and practical aspects of OOP with Java.
Page 2
OBJECT-ORIENTED PROGRAMMING with JAVA 3
Page 3
OBJECT-ORIENTED PROGRAMMING with JAVA 4
Acknowledgement
We thank Almighty God for giving us the strength and the courage to overcome all
difficulties.
We would like to express our most sincere thanks to the people who helped us in the
preparation of this report and throughout this academic year.
Our sincere thanks go to the teaching staff of our university and the Department of Computer
Science.
Finally, we are very grateful to our family and friends, who supported and encouraged us
during the creation of this report.
Many thanks to all of you.
Page 4
OBJECT-ORIENTED PROGRAMMING with JAVA 5
Introduction
Page 5
OBJECT-ORIENTED PROGRAMMING with JAVA 6
A class is a blueprint defining the attributes and behaviors common to similar objects. For
example, a Car class would describe attributes (color, make) and methods (accelerate(),
brake()).
An object is a specific instance of a class, existing in memory with its own attribute values.
Instantiation refers to creating an object from a class.
Attributes store an object's state (e.g., name for a Student), while methods define actions (e.g.,
calculateAverage()). The close link between data and methods forms the foundation of
encapsulation.
Page 6
OBJECT-ORIENTED PROGRAMMING with JAVA 7
Encapsulation
Encapsulation links data and the methods that manipulate them within a class, while
restricting direct access to internal components.
It protects data integrity by declaring attributes private and providing controlled access
through public methods such as getters and setters.
Advantages include modularity, maintainability, and improved data security. Java uses access
modifiers (public, private, protected, package-private) to implement encapsulation, typically
using private attributes with public getters/setters.
Page 7
OBJECT-ORIENTED PROGRAMMING with JAVA 8
Inheritance
Inheritance enables a new class (subclass) to acquire the attributes and methods of an existing
class (superclass), promoting code reuse and hierarchical organization.
Common features are defined in the superclass (e.g., Animal with name, eat()), while
subclasses (e.g., Dog, Cat) inherit and may add specific features.
Inheritance models "is-a" relationships and supports method overriding. In Java, it is
implemented using the extends keyword and the super keyword to access superclass
members.
Page 8
OBJECT-ORIENTED PROGRAMMING with JAVA 9
Polymorphism
Polymorphism allows objects of different classes to respond to the same method call in ways
appropriate to their types.
Derived class objects are treated as base class objects, but the overridden method specific to
their class is executed at runtime.
Java supports both compile-time polymorphism (method overloading) and runtime
polymorphism (method overriding), enabling flexible and extensible designs.
Page 9
OBJECT-ORIENTED PROGRAMMING with JAVA 10
Abstraction
Page 10
OBJECT-ORIENTED PROGRAMMING with JAVA 11
Java supports all core OOP principles. Class definitions use the class keyword. Objects are
created using the new keyword and initialized with constructors.
The this keyword distinguishes instance variables. Java enables encapsulation, inheritance,
polymorphism, and abstraction using its syntax and features like access modifiers, interfaces,
and abstract classes.
These features make Java a strong tool for building robust, maintainable applications.
Page 11
OBJECT-ORIENTED PROGRAMMING with JAVA 12
Conclusion
This report detailed the concepts of Object-Oriented Programming (OOP) and their
implementation in Java.
Key principles such as encapsulation, inheritance, polymorphism, and abstraction were
explored, with emphasis on their practical applications.
Java’s features support OOP effectively, enabling the development of modular, reusable, and
scalable software. Mastering these concepts is essential for modern software development.
Page 12
OBJECT-ORIENTED PROGRAMMING with JAVA 13
References
Page 13