OOP Principle
Definition of OOPS Concepts in Java
So we can define OOP programming as:
“Object-oriented programming is an approach that modularizes programs by creating a partitioned memory area for both functions and data that can be used as templates for creating copies of such modules on demand.”
OOPS Paradigm
The primary objective of the object-oriented approach is to eliminate some of the pitfalls that exist in the procedural approach.
Object = Method + Data
The data of an object is accessed by the methods associated with that object. However, the methods of an object can access methods of other objects.
Features of OOPS
Some features of object-oriented programming in java are:
- Emphasis is on data than procedures
- Programs are divided into objects
- Data Structures are designed to characterize objects.
- Methods operating on the data of an object are tied together in the data structure.
- Data is hidden, and external functions cannot access it.
- Objects communicate with each other through methods
- New methods and data can be easily added whenever necessary
- Follows the bottom-up approach in program design
List of OOPS Concepts in Java with Examples
1.Objects and Classes
Objects are runtime entities in an object-oriented system. An object can represent a person, a bank account, a place, a table of data. It may also represent user-defined data types like lists and vectors.
The collection of objects of similar types is termed as a class. For Example, apple, orange, and mango are the objects of the class Fruit. Classes behave like built-in data types of a programming language but are user-defined data types.
2.Data Abstraction and Encapsulation
The wrapping up of the data and methods into the single unit is known as encapsulation. The data is accessible only to those methods, which are wrapped in the class, and not to the outside world.
3.Inheritance
Inheritance is the process by which objects of one class acquire some properties of objects of another class. Inheritance supports the concept of hierarchical classification.
Types of Inheritance
- Single
- Multiple
- Multilevel
- Hybrid
4.Polymorphism
Polymorphism is an important OOP concept; it means the ability to take many forms. For Example, an operation exhibits different behavior in different situations. The behavior depends on the type of data used in operation.
The figure below demonstrates that a single function name can be used to handle the different numbers and different types of arguments.
5.Dynamic Binding
Binding is the process of linking a procedure call to the code to be executed in response to the call. It means that the code associated with the given procedure call is not known until the time of the call at runtime.
Objects communicate with each other in OOPs The process of programming in case of OOP consists of the following:
- Creating classes defining objects and their behavior.
- Creating objects
- Establishing communication between objects.
The network of Objects Communicating with Each Other
Benefits of OOPs Concept in Java
- Inheritance eliminates redundant code and enables reusability.
- As Message passing allows communication with objects, this presents writing code from scratch every time. It is thus saving development time and higher productivity.
- Partitions work in a project based on classes and objects.
- Systems up-gradation is easy.
Applications of OOPs Concept in Java
- Real-time systems
- Simulation and modeling
- Object-oriented databases
- Hypertext and Hypermedia
- AI and expert systems
- Neural networks and parallel programming
- Automation systems
Summary
Java is a robust and scalable object-oriented programming language that is based on the concept of objects and classes. It offers features like inheritance, abstraction, encapsulation, and polymorphism for developing an efficient and reliable code.