What is object-oriented programming (OOP) in one sentence?
Options
- Writing code only with real-world objects such as cars
- Organizing code into objects that bundle data and behavior (Correct option)
- Writing programs that contain no functions
- Running a program on several computers at once
Answer
Organizing code into objects that bundle data (state) and behavior (methods)
Why
In OOP you model things of your program as objects. An object keeps its data in fields and exposes actions through methods. For example, an Account object has a balance and a deposit() method.
Benefits listed by the Java tutorial: modularity, information hiding, code re-use and easy debugging or replacement of one object.
Java, Python, C# and C++ support it.
Remember
OOP = objects with data + behavior.