Object-oriented programming aims to implement real-world entities, for example, objects, classes, abstraction, inheritance, polymorphism, etc. https://bit.ly/3U1BWhF
C O NC E P T S I N J A V A OOPS Object-oriented programming is a paradigm that provides concepts such as inheritance, data binding, polymorphism, etc
3.
What is OOPS? Object-oriented programmingaims to implement real-world entities, for example, objects, classes, abstraction, inheritance, polymorphism, etc. Object means a real-world entity such as a pen, chair, table, computer, watch, etc. Object-oriented programming is a methodology or paradigm for designing a program using classes and objects.
4.
Origin of OOPS Simulais considered the first object- oriented programming language. The programming paradigm where everything is represented as an object is known as a pure object-oriented programming language. Smalltalk is considered the first truly object-oriented programming language.
OBJECT IN OOPS AnObject can be defined as an instance of a class. It contains an address and takes up some space in memory. Objects can communicate without knowing the details of each other's data or code. The only necessary thing is the type of message accepted and the type of response returned by the objects.
7.
The primary elementsof an object are: State: It is embodied in an object's properties. Additionally, it reflects an object's attributes. Identity: Identity is a special name that gives a thing the ability to communicate with other objects. Behavior: An object's methods are a representation of it. Additionally, it represents how an object reacts to other objects. Method: A Group of statements that perform a specific operation
8.
Core OOPs Concepts Object Instance ofa class with state and behavior Class Blueprint from which objects are created Inheritance Acquiring properties and behaviors from parent objects Polymorphism Performing one task in different ways Abstraction Hiding implementation, showing only functionality Encapsulation Binding code and data together into a single unit
9.
ABSTRACTION Hiding internal implementationand showing functionality only to the user is known as abstraction. For example, in phone calls, we are unaware of the internal processing. In Java, we use abstract classes and interfaces to achieve abstraction.
10.
ENCAPSULATION Binding (or wrapping)code and data together into a single unit is known as encapsulation. For example, a capsule is wrapped with different medicines. A Java class is an example of encapsulation. A Java bean is a fully encapsulated class because all the data members are private.
11.
ADVANTAGE OF OOPS 1.OOPs make development and maintenance easier, whereas in a procedure-oriented programming language, it is not easy to manage if the code grows as the project size increases. 2. OOP provides data hiding, whereas in a procedure-oriented programming language, global data can be accessed from anywhere. 3. OOPs provide the ability to simulate real-world events much more effectively. We can provide the solution to real-world problems if we use an Object-Oriented Programming language.
13.
Advanced OOP Relationships Coupling Knowledgeor dependency between classes. Strong coupling occurs when classes are highly aware of each other. Interfaces help create weaker coupling. Cohesion The level of a component performing a single well- defined task. Highly cohesive methods perform one task well, while weakly cohesive methods split tasks into separate parts. Association Relationship between objects (one-to-one, one-to-many, many- to-one, many-to- many). Can be unidirectional or bidirectional. Aggregation A way to achieve an Association where one object contains others as part of its state (HAS-A relationship). Represents a weak relationship between objects. Composition A strong relationship where dependent objects cannot exist independently. If the parent object is deleted, all child objects are deleted automatically.