The document provides an introduction to object-oriented programming (OOP) by comparing it to procedural programming. It discusses key OOP concepts like classes, objects, encapsulation, inheritance, polymorphism, and message passing. OOP focuses on data as a critical element and emphasizes data over procedures by dividing programs into objects that communicate through methods.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
29 views23 pages
Unit 1 Introduction To OOP
The document provides an introduction to object-oriented programming (OOP) by comparing it to procedural programming. It discusses key OOP concepts like classes, objects, encapsulation, inheritance, polymorphism, and message passing. OOP focuses on data as a critical element and emphasizes data over procedures by dividing programs into objects that communicate through methods.
• Well structured steps and procedures using functions
to perform tasks or logic • Follows top to bottom approach • Functions are more important than data • Doesn’t model real world problems since functions are action oriented Characteristics of procedural programming • Emphasis on algorithms (action or logic) • Large programs are divided into small programs known as functions or modules • Top down approach • Data are shared globally • Data move from function to function Object Oriented Programming • Based on object and classes • Data contained in the form of attributes or properties • Logic contained in the form of procedures known as methods or behavior • Concepts like Inheritance, Polymorphism, Abstraction, Encapsulation, etc. • Unlike procedural approach, OOP treats data as critical element and doesn’t allow flowing freely around system • Data is accessed by only function associated with object • However, functions of one object can access function of other objects Characteristics of OOP • Emphasis on data rather than procedure • Programs are divided into parts known as objects • Access modifiers are specified • Data are hidden and cannot be accessed by external functions • Objects communicates with each other throw functions (also called message passing or method invocation) • Follows bottom up approach Difference between object-oriented and procedure-oriented programming. Terms used in OOP Objects • Representation of entities with both data and behavior • For example a Car class can have attributes like color, model and behaviors like accelerate, start engine. Each car object can have its own unique values for these attributes • Objects take up space in memory and have associated address just like structure or union in C • Objects are variables of type class Class • Blueprint or template that describes the properties (attributes) and behaviors (methods) that object will hold • Serves as blueprint for creating multiple objects with similar characteristics • It defines structure and behavior of object but doesn’t hold actual data Data Abstraction • Showing only essential information or characteristics of an object to outside world while hiding the implementation details • Focuses on what object does rather than how Data Encapsulation • Bundling data and methods that operate on that data into a single unit • Grouping data and methods and providing control over access and visibility • Mainly used to provide data security by limiting access to data using the methods defined within a class • To prevent unauthorized and inconsistent changes in data Inheritance • Process by which the objects acquire the properties and methods of another class • To share common characteristics of a class from which it is derived • Provides the reusability advantage • We can also add additional features to existing class without modifying it Polymorphism (overriding and overloading) • Ability to make more than one form • Allows us to treat different objects in a similar way, even if they belong to different class • Promotes code reusability and flexibility Dynamic Binding • Process of resolving appropriate function to be called at runtime using inheritance or polymorphism • Known as late binding or runtime polymorphism Message Passing • Communication between objects by sending and receiving information • Using method calls or function invocations • Involves in sending message to an object, which triggers the execution of specific function associated with that object • Advantages of OOP • Application areas of OOP