0% found this document useful (0 votes)
103 views3 pages

Object Oriented Programming: Answer

Object-oriented programming (OOP) is a programming paradigm that uses "objects" and their interactions to design applications. Key characteristics of OOP include information hiding, data abstraction, encapsulation, modularity, polymorphism, and inheritance. Encapsulation combines data and functions into a single unit called a class. Data encapsulation leads to data hiding, where the implementation details of a class are hidden from the user. This restricted access requires specialized functions or methods to perform operations on hidden class members.

Uploaded by

Darya Memon
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
103 views3 pages

Object Oriented Programming: Answer

Object-oriented programming (OOP) is a programming paradigm that uses "objects" and their interactions to design applications. Key characteristics of OOP include information hiding, data abstraction, encapsulation, modularity, polymorphism, and inheritance. Encapsulation combines data and functions into a single unit called a class. Data encapsulation leads to data hiding, where the implementation details of a class are hidden from the user. This restricted access requires specialized functions or methods to perform operations on hidden class members.

Uploaded by

Darya Memon
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 3

Question 12

C++ assignment

Q.12: What is object oriented programming? Write its advantage and characteristics in detail.
What we mean by the term Data Encapulation.

Answer:

Object Oriented Programming


Object-oriented programming (OOP) is a programming paradigm that uses "objects" and their interactions to design applications and computer programs. Programming techniques may include features such as information hiding, data abstraction, encapsulation, modularity, polymorphism, and inheritance. It was not commonly used in mainstream software application development until the early 1990s. Many modern programming languages now support OOP.

Object-oriented programming has roots that can be traced to the 1960s. As hardware and software became increasingly complex, quality was often compromised. Researchers studied ways to maintain software quality and developed object-oriented programming in part to address common problems by strongly emphasizing discrete, reusable units of programming logic. The methodology focuses on data rather than processes, with programs composed of self-sufficient modules (objects) each containing all the information needed to manipulate its own data structure. This is in contrast to the existing modular programming which had been dominant for many years that focused on the function of a module, rather than specifically the data, but equally provided for code reuse, and self-sufficient reusable units of programming logic, enabling collaboration through the use of linked modules (subroutines). This more conventional approach, which still persists, tends to consider data and behavior separately.

An object-oriented program may thus be viewed as a collection of cooperating objects, as opposed to the conventional model, in which a program is seen as a list of tasks (subroutines) to perform. In OOP, each object is capable of receiving messages, processing data, and sending messages to other objects and can be viewed as an independent 'machine' with a distinct role or responsibility. The actions (or "operators") on these objects are closely associated with the object. For example, the data structures tend to carry their own operators around with them (or at least "inherit" them from a similar object or class).

09CE37

32

Question 12

C++ assignment

Data Encapsulation
Encapsulation is the process of combining data and functions into a single unit called class. Using the method of encapsulation, the programmer cannot directly access the data. Data is only accessible through the functions present inside the class. Data encapsulation led to the important concept of data hiding. Data hiding is the implementation details of a class that are hidden from the user. The concept of restricted access led programmers to write specialized functions or methods for performing the operations on hidden members of the class. Attention must be paid to ensure that the class is designed properly.

Neither too much access nor too much control must be placed on the operations in order to make the class user friendly. Hiding the implementation details and providing restrictive access leads to the concept of abstract data type. Encapsulation leads to the concept of data hiding, but the concept of encapsulation must not be restricted to information hiding. Encapsulation clearly represents the ability to bundle related data and functionality within a single, autonomous entity called a class. For instance:

class 09ce { public: int sample(); int example(char *se) int endfunc(); ......... ......... //Other member functions private: int x; float sq; .......... ......... //Other data members }; In the above example, the data members integer x, float sq and other data members and member functions sample(),example(char* se),endfunc() and other member functions are bundled and put inside a single autonomous entity called class Exforsys. This exemplifies the concept of Encapsulation. This special feature is available in object-oriented language C++ but not available in procedural language C. There are advantages of using this encapsulated approach in C++. One advantage is that it reduces human errors. The data and functions bundled inside the class take total control of maintenance and thus human errors are reduced. It is clear from the above example that the encapsulated objects act as a black box for other parts of the program through interaction. Although encapsulated objects provide functionality, the calling objects will not know the implementation details. This enhances the security of the application. The key strength behind Data Encapsulation in C++ is that the keywords or the access specifiers can be placed in the class declaration as public, protected or private. A class

09CE37

33

Question 12

C++ assignment

placed after the keyword public is accessible to all the users of the class. The elements placed after the keyword private are accessible only to the methods of the class. In between the public and the private access specifiers, there exists the protected access specifier. Elements placed after the keyword protected are accessible only to the methods of the class or classes derived from that class. The concept of encapsulation shows that a non-member function cannot access an object's private or protected data. This adds security, but in some cases the programmer might require an unrelated function to operate on an object of two different classes. The programmer is then able to utilize the concept of friend functions. Encapsulation alone is a powerful feature that leads to information hiding, abstract data type and friend functions.

09CE37

34

You might also like