Repaso
EspaƱol
Design & PracticesFoundationsDP-56

What is object-oriented programming (OOP) in one sentence?

Options

  1. Writing code only with real-world objects such as cars
  2. Organizing code into objects that bundle data and behavior (Correct option)
  3. Writing programs that contain no functions
  4. 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.

Key terms

Practice this question in Repaso