OOPS Unit 1 & 2 PDF

Summary

This document introduces object-oriented programming (OOP) concepts such as classes, objects, and methods. It uses simple examples of code and explanations of terminology.

Full Transcript

What is object oriented Programming ? Explain difference between OOP and POP. 1.1. Procedure Oriented Programming Vs Object Oriented Programming Procedure Oriented Programming Object Oriented Programming In POP, program is divided into small parts...

What is object oriented Programming ? Explain difference between OOP and POP. 1.1. Procedure Oriented Programming Vs Object Oriented Programming Procedure Oriented Programming Object Oriented Programming In POP, program is divided into small parts OOP, program is divided into parts called objects. called functions. In POP, Importance is not given to data but In OOP, Importance is given to the data rather to functions as well as sequence of actions than procedures or functions because it works as a to be done. real world. POP follows Top Down approach. OOP follows Bottom Up approach. OOP has access specifiers named Public, POP does not have any access specifier. Private,Protected, etc. In POP, Data can move freely from function In OOP, objects can move and communicate with to function in the system. each other through member functions. To add new data and function in POP is OOP provides an easy way to add new data notso easy. andfunction. In POP, Most function uses Global data for In OOP, data can not move easily from function to sharing that can be accessed freely from function ,it can be kept public or private so we can function to function. control the access of data. POP does not have any proper way for OOP provides Data Hiding so provides hiding data so it is less secure. moresecurity. In OOP, overloading is possible in the form of In POP, Overloading is not possible. Function Overloading and Operator Overloading. Example of POP are : C, VB, FORTRAN, Example of OOP are : C++, JAVA, VB.NET, C#.NET. Pascal. Introduction Of OOP C++ began as an expanded version of C. The C++ were first invented by BjarneStroustrup in 1980 at Bell Laboratories in Murray Hill, New Jersey. This new language was initially called "C with Classes". Object Oriented Programming is a programming in which we design and develop our application or program based of object. Objects are instances(variables) of class. Basic Concept Of OOP (Features Of OOP): Que: List out basic concepts of OOP. Explain any two in brief. OBJECT: Object is a collection of number of entities. Objects take up space in the memory. Objects are instances of classes. When a program is executed , the objects interact by sending messages to oneanother. Each object contain data and code to manipulate the data. Objects can interactwithout having know details of each others data or code. CLASS: Class is a collection of objects of similar type. Class is a collection of data member and member function. Objects are variables of the type class. Once a class has been defined, we can create any number of objects belonging tothat class. Eg: grapes bannans and orange are the member of class fruit. Example: Fruit orange; In the above statement object mango is created which belong to the class fruit. NOTE: Classes are user define data types. DATA ABSTRACTION AND ENCAPSULATION: Combining data and functions into a single unit called class and the process is knownas Encapsulation. Data encapsulation is important feature of a class. Class contains both data andfunctions. Data is not accessible from the outside world and only those function which arepresent in the class can access the data. The protection of the data from direct access by the program is called data hiding orinformation hiding. Hiding the complexity of program is called Abstraction and only essential features are represented. In short we can say that internal working is hidden. DYNAMIC BINDING: Refers to linking of function call with function definition is called binding and whenit is take place at run time called dynamic binding. MESSAGE PASSING: The process by which one object can interact with other object is called messagepassing. INHERITANCE: It is the process by which object of one class aquire the properties or features ofobjects of another class. The concept of inheritance provide the idea of reusability means we can addadditional features to an existing class without Modifying it. This is possible by driving a new class from the existing one. The new class will havethe combined features of both the classes. Example: Robine is a part of the class flying bird which is again a part of the class bird. POLYMORPHISM: A greek term means ability to take more than one form. An operation may exhibite different behaviours in different instances. The behaviour depends upon the types of data used in the operation. Example: Operator Overloading Function Overloading Benefits Of OOP: Through inheritance, we can eliminate redundant code and extend the use of existing classes which is not possible in procedure oriented approach. We can build programs from the standard working modules that communicate with one another, rather than having to start writing the code from scratch which happens procedure oriented approach. This leads to saving of development time and higher productivity. The principle of data hiding helps the programmer to build secure programs thatcannot be invaded by code in other parts of the program. It is possible to have multiple instances of object to co-exist without anyinterference. It is possible to map objects in the problem domain to those in the program. It is easy to partition the work in a project based on objects. The data-centered design approach enables us to capture more details of a model inimplementable from. Object oriented systems can be easily upgraded from small to large systems. Message passing techniques for communication between objects makes theinterface descriptions with external systems much simpler. Software complexity can be easily managed. C++ Programming:= C++ is a object oriented Programming Language. It was developed by Bjarne Stroustrup at AT & T Bell Laboratries in New Jersey,USA 1980. C++ Basic Program:= #include #inclulde void main() { cout

Use Quizgecko on...
Browser
Browser