group-icon
Java Developers
Group for Java developers and programmers. Ask questions and get answers related to Java programming
263 Members
Join this group to post and comment.
Gaurav Prasad
Gaurav Prasad
Computer Science
15 Jan 2019

What are OOP (Object Oriented Programming) Concepts?

What are the various OOP aka object oriented programming concepts. Could you describe them all? 

Archana Priyadarshini
Archana Priyadarshini
Computer Science
3mos ago

Oops concepts:-

  1. Encapsulation is a mechanism of wrapping the data (variables) and code acting on the data (methods) together as a single unit.
  2. Abstraction is selecting data from a larger pool to show only the relevant details to the object. It does not focus on the background complexities.
  3. Polymorphism is the concept where an object behaves differently in different situations.
  4. Inheritance is a mechanism in which one class acquires the property of another class.
  5. Association defines a relationship between classes of objects that allows one object instance to cause another to perform an action on its behalf.
  6. Aggregation is a special form of association. It is a relationship between two classes like association however it is directional, which means it is strictly a one way association.
  7. Composition is a restricted form of Aggregation in which two entities are highly dependent on each other.

Shruthi Pillai
Shruthi Pillai
Information Technology
3mos ago

Object-Oriented Programming is a methodology  to design a program using classes and objects.  There are four main OOP concepts in Java.

Inheritance

It lets programmers create new classes that share some of the attributes of existing classes. It provides code reusability.  

Polymorphism

If one task performed by different ways, it is known as polymorphism.  In Java, we use method overloading and method overriding to achieve polymorphism.

Abstraction

In Java, abstraction means simple things like objects, classes, and variables represent more complex underlying code and data.  It lets avoid repeating the same work multiple times. In Java, we use abstract class and interface to achieve abstraction.

Encapsulation

Binding code and data together into single unit.A java class is the example of encapsulation.

3mos ago

Object Oriented Programming has been defined pretty well in textbooks. The only thing that matters in practical application is how the programmer makes use of those objects. It's super easy to write bad code with OOP approach. 

There's also a misconception that OOP is a better approach over the traditional functional programming approach. I beg to differ - OOP is a better approach when the overall complexity of the project grows. There's no point in opting for OOP if the overall code is just a few lines of code ( a few hundred, maybe). 

In my opinion, OOP allows us to organise our code well so that it's maintainable. As the project grows bigger in size and complexity, you need reusable classes and methods and that's where you can make use of Inheritance, Polymorphism, Abstraction, Encapsulation et al. 

However, the bottom line is that it all depends upon the programmer or developer. As I said - it's pretty easy to make the project super complicated to understand with BAD programming - be it OOP or Functional. 

Gaurav Prasad
Gaurav Prasad
Computer Science
3mos ago

thanks for all your efforts.