1.

What do you understand about Object Oriented Programming? Explain the major features of object oriented programming.

Answer»

Object-oriented programming (OOP) is a programming paradigm that organises software design around data, rather than functions and logic. An object is a data field with its own set of properties and behaviour. Object-oriented programming (OOP) focuses on the objects that developers desire to handle rather than the logic that is required to manipulate them. This kind of programming is ideally suited to big, complicated, and frequently updated or maintained projects. Inheritance, hiding, polymorphism, and other real-world concepts are all part of object-oriented programming. The basic goal of OOP is to connect data and the functions that operate on it so that no other part of the code may access it except that function.

Following are the major FEATURES of Object-Oriented Programming:

  • Encapsulation: The word "encapsulate" refers to the act of enclosing something. Encapsulation works in OOP in a similar fashion to how a pill "encapsulates" or contains the medication under its coating: by building a protective barrier around the information contained within a class from the rest of the code. In OOP, we encapsulate data and methods that operate on it by combining them into a single unit, the class. We can hide the private information of a class from the outside world and only disclose functionality that is needed to interact with it this way. We say a class is properly enclosed when it prevents calling code from accessing its private data directly.
    • For example, consider a multinational company. There are various sectors in a firm, such as the accounts, finance, and sales departments. The finance department is in CHARGE of all financial transactions and keeps track of all financial data. Similarly, the sales department is in charge of all sales-related activities and keeps track of all sales. Now and then, a circumstance may arise in which a finance official requires complete sales data for a specific month for some reason. In this instance, he is not permitted to view the sales section's data directly. He must first contact ANOTHER officer in the sales department and request that he provide the requested information. Encapsulation is what it is. The data from the sales area, as well as the employees who can change it, are grouped together under the heading "sales section."
  • Abstraction: Abstraction is the technique of hiding unnecessary details and displaying only the necessary details. The practice of identifying only the required attributes of an object while discarding the irrelevant information is known as data abstraction. The features and behaviours of an object assist to distinguish it from other THINGS of the same sort, as well as classifying and grouping them.
    • For example, consider an ATM machine. In our daily lives, we all utilise an ATM machine for cash withdrawals, money transfers, retrieving minimum statements, and so on. However, we have no idea what happens inside an ATM machine when you insert an ATM card to execute any type of transaction.
  • Inheritance: Inheritance is the technique in Object-Oriented Programming by which one class can acquire all the properties of another class and can even add more properties to its definition. Inheritance, therefore, enforces code reusability. The class whose properties are being inherited is referred to as a base or parent class while the class which inherits the properties of another class is referred to as sub or child class.
    • For example, A child inherits a LOT of physical features from his/ her parents. People often compare whether a particular feature is the same as that of the father or the mother. There are different types of vehicles such as cars, buses, trucks and so on. All of these different types of vehicles can be believed to have inherited all the basic properties of a Vehicle which includes an accelerator, brake and so on.
  • Polymorphism: Polymorphism is the technique of using one thing in more than one form. Polymorphism, in other terms, allows you to specify a single interface with various implementations.
    • For example, a person can have different relations with different people around them. A person may be a father to a son, a brother to a sister, a son to a mother and so on. Similarly, a person may behave differently depending on the situation. For example, two people in an office are considered colleagues during work hours, but they can be friends after office hours. When you're in class, you act like a student; when you're in the store, you act like a customer; when you're at home, you act like a son or daughter; here, one person exhibits a variety of behaviours.


Discussion

No Comment Found