CSC166 Object Oriented Programming

Object Oriented ProgrammingTU Board 2082

List and describe the characteristics of object oriented programming.

5

Answer

Object-oriented programming (OOP) organises a program around objects, which combine data and the functions that work on that data. Its main characteristics are:

  1. Class and object. A class is a user-defined type, a blueprint that describes data members and member functions. An object is an instance of a class. For example, Student is a class and s1 is an object of it.
  2. Encapsulation. Data and the functions that operate on it are wrapped together in a class, and the data is usually kept private, so it can only be changed through the class's own functions.
  3. Data abstraction. Only the essential features are shown to the user and the implementation details are hidden. You call stack.push(5) without knowing how the stack is stored.
  4. Inheritance. A new class (derived class) can reuse the properties of an existing class (base class) and add its own. Car can inherit from Vehicle. This supports code reuse.
  5. Polymorphism. "One name, many forms": the same function or operator behaves differently in different contexts. Examples are function overloading, operator overloading (compile time) and virtual functions (run time).
  6. Dynamic binding. The function to be called is decided at run time, based on the actual object, through virtual functions.
  7. Message passing. Objects communicate by calling each other's member functions, such as account.deposit(500).

Other features are the bottom-up design approach and the emphasis on data rather than procedures, which makes programs easier to maintain and extend.

Discussion

Loading…

More Object Oriented Programming questions

All Object Oriented Programming old questions