Object Oriented ProgrammingTU Board 2082
List and describe the characteristics of object oriented programming.
5Answer
Object-oriented programming (OOP) organises a program around objects, which combine data and the functions that work on that data. Its main characteristics are:
- 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,
Studentis a class ands1is an object of it. - 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. - 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. - Inheritance. A new class (derived class) can reuse the properties of an existing class (base class) and add its own.
Carcan inherit fromVehicle. This supports code reuse. - 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).
- Dynamic binding. The function to be called is decided at run time, based on the actual object, through virtual functions.
- 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
A book shop maintains the inventory of books that are being sold at the shop. The list includes details such as author, title, price, publisher and stock…TU Board 208210Define polymorphism? List its advantages, write program to perform basic to user defined data type conversion.TU Board 208210Distinguish between public and private inheritance. Illustrate the chain of constructors and destructors in derived class with an example.TU Board 208210Write any two types of storage class? Write a program to calculate Power (a, b), using default arguments, if second argument is omitted, then calculate square…TU Board 20825Explain copy constructor with an example.TU Board 20825Is multiple inheritance possible? List some advantages and disadvantages of inheritance.TU Board 20825