Object Oriented Programming. C++ 6 th Sem, A Div Ms. Mouna M. Naravani

Similar documents
STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING

Data Structures and Programming with C++

PROGRAMMING IN C++ COURSE CONTENT

OBJECT ORIENTED PROGRAMMING

BASIC CONCEPT OF OOP


Constructors and Destructors. OOC 4 th Sem, B Div Prof. Mouna M. Naravani

Unit 1 : Principles of object oriented programming

Data Structures using OOP C++ Lecture 3

Unit - IV CHAPTER - 13 INTRODUCTION TO OOP WITH C++ Part 1 Choose the best answer

What are the characteristics of Object Oriented programming language?

Advantages of Object Oriented Programming :- Features of Object Oriented Programming :- Advantages Of Object Oriented Programming :

Friend Functions. OOC 4 th Sem, B Div Prof. Mouna M. Naravani

Elementary Concepts of Object Class

Object Oriented Pragramming (22316)

Object Oriented Programming using C++

Object-Oriented Programming

Static Members. OOC 4 th Sem, B Div Prof. Mouna M. Naravani

MAHALAKSHMI ENGINEERING COLLEGE B TIRUCHIRAPALLI

Sri Vidya College of Engineering & Technology

Object oriented programming Concepts

1. Write two major differences between Object-oriented programming and procedural programming?

Object-Oriented Programming (OOP) Fundamental Principles of OOP

Object Oriented Programming. Assistant Lecture Omar Al Khayat 2 nd Year

Object Orientated Analysis and Design. Benjamin Kenwright

CHAPTER 5 GENERAL OOP CONCEPTS

Object-Oriented Concepts and Principles (Adapted from Dr. Osman Balci)

Basics of Object Oriented Programming. Visit for more.

Lecture 1. Abstraction

Microsoft Visual Basic 2005: Reloaded


OOPs Concepts. 1. Data Hiding 2. Encapsulation 3. Abstraction 4. Is-A Relationship 5. Method Signature 6. Polymorphism 7. Constructors 8.

Data Structures (list, dictionary, tuples, sets, strings)

Overview of OOP. Dr. Zhang COSC 1436 Summer, /18/2017

CS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University

Lesson Plan. Subject: OBJECT ORIENTED PROGRAMMING USING C++ :15 weeks (From January, 2018 to April,2018)

UML Primer. -Elango Sundaram

Jaipur National University, Jaipur Dr. Rajendra Takale Prof. and Head Academics SBPIM, Pune

Object Oriented Programming

Programming II (CS300)

Paytm Programming Sample paper: 1) A copy constructor is called. a. when an object is returned by value

Programming II (CS300)

I BCS-031 BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination. June, 2015 BCS-031 : PROGRAMMING IN C ++

CS 6456 OBJCET ORIENTED PROGRAMMING IV SEMESTER/EEE

Classes, objects, methods and properties

What is a Programming Paradigm

Part 7 - Object Oriented Concepts Classes, Objects, Properties and Methods

Lesson 10B Class Design. By John B. Owen All rights reserved 2011, revised 2014

Introduction to Object-Oriented Programming

STRUCTURING OF PROGRAM

SRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR

Oops known as object-oriented programming language system is the main feature of C# which further support the major features of oops including:

PROGRAMMING LANGUAGE 2

JAVA: A Primer. By: Amrita Rajagopal

Master of Computer Applications

CREATED BY: Muhammad Bilal Arslan Ahmad Shaad. JAVA Chapter No 5. Instructor: Muhammad Naveed

Introduction to OOP. Procedural Programming sequence of statements to solve a problem.

Java Class Design. Eugeny Berkunsky, Computer Science dept., National University of Shipbuilding

Namespaces. OOC 4 th Sem, B Div Prof. Mouna M. Naravani

Study Material for MCA-302/MS-17

VALLIAMMAI ENGINEERING COLLEGE

The University Of Michigan. EECS402 Lecture 06. Andrew M. Morgan. Savitch Ch. 6 Intro To OOP Classes Objects ADTs.

Chapter 13 Object Oriented Programming. Copyright 2006 The McGraw-Hill Companies, Inc.


DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING CS6456 OBJECT ORIENTED PROGRAMMING

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING REWRAP TEST I CS6301 PROGRAMMING DATA STRUCTURES II

Object Oriented Programming with c++ Question Bank

10. Abstract Data Types

Object-Oriented Languages and Object-Oriented Design. Ghezzi&Jazayeri: OO Languages 1

Inheritance Inheritance :

CLASSES AND OBJECTS IN JAVA

Get Unique study materials from

OOPS Viva Questions. Object is termed as an instance of a class, and it has its own state, behavior and identity.

Object Oriented Programming. Solved MCQs - Part 2

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe

3.Constructors and Destructors. Develop cpp program to implement constructor and destructor.

Examples. Object Orientated Analysis and Design. Benjamin Kenwright

Imperative Languages!

BCS THE CHARTERED INSTITUTE FOR IT. BCS HIGHER EDUCATION QUALIFICATIONS BCS Level 5 Diploma in IT OBJECT ORIENTED PROGRAMMING

CS304 Object Oriented Programming Final Term

COMP 202. More on OO. CONTENTS: static revisited this reference class dependencies method parameters variable scope method overloading

Object Oriented Programming(OOP).

Chapter 5 Object-Oriented Programming

Chapter3: Introduction to Classes and Objects

JAVA MOCK TEST JAVA MOCK TEST II

Hierarchical inheritance: Contains one base class and multiple derived classes of the same base class.

OOPs: The Harsh Realities of Programming

SEEM4570 System Design and Implementation. Lecture 11 From Design to Implementation

Chapter 02 Building Multitier Programs with Classes

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING OBJECT ORIENTED PROGRAMMING CLASS : THIRD SEMESTER CSE

Programming Language Concepts Object-Oriented Programming. Janyl Jumadinova 28 February, 2017

Object-Oriented Programming Concepts

Object Oriented Programming With C By Balagurusamy 5th Edition

Object Oriented Programming in Java. Jaanus Pöial, PhD Tallinn, Estonia

Inheritance, and Polymorphism.

INHERITANCE: EXTENDING CLASSES

B16 Object Oriented Programming

C++ Important Questions with Answers

write the functions inside as well as outside the class. So in C++, they are called member functions and not methods.

Object- Oriented Design with UML and Java Part I: Fundamentals

Transcription:

Object Oriented Programming C++ 6 th Sem, A Div 2018-19 Ms. Mouna M. Naravani

Object Oriented Programming (OOP) removes some of the flaws encountered in POP. In OOPs, the primary focus is on data rather than procedure. The data cannot be moved freely around the system. OOPs ties data more closely to the functions that operate on it, and protects it from accidental modification from outside functions. The functions cannot exist without data, and data need functions to give it a shape.

Organization of data and functions in OOP

OOP allows decomposition of a problem into a number of entities called objects and then builds data and functions around these objects. Data is hidden and cannot be shared by outside functions. The data of an object can be accessed only by the functions associated with that object. The objects that are created may interact with each other via functions. OOPs follows Bottom-up approach, because the objects are created first and the data and functions around them are developed later.

Some of the striking features of object-oriented programming are: Emphasis is on data rather than procedure. Programs are divided into what are known as objects. Data structures are designed such that they characterize the objects. Data is hidden and cannot be accessed by external functions. Objects may communicate with each other through functions. New data and functions can be easily added whenever necessary. Follows bottom-up approach in program design.

Basic concepts of Object Oriented Programming Classes Message Passing Objects OOP Polymorphism Inheritance Data Abstraction and Encapsulation

Objects: Objects are basic run time entities in OOP. It may represent a person, a bank account, a place, a table of data, vectors, etc. Objects should be chosen such that they match closely with real-world objects. Ex: Name, DOB, Address, Age, Mobile number. If these details are required for student, create STUDENT object. If these details are required for customer, create CUSTOMER object. If these details are required for employee, create EMPLOYEE object. Objects occupy space in the memory and have an associated address. When a program is executed, the objects interact by sending messages to one another. Ex: If CUSTOMER and ACCOUNT are two objects, then the CUSTOMER object may send a message to the ACCOUNT object requesting for bank balance.

Objects contain both data and operations that manipulate these data. Objects can interact without having to know details of each other s data or code. It is sufficient to know the type of message accepted, and the type of response returned by the objects.

Classes: A class is a collection of objects of similar type. Ex: mango, apple and orange are members of the class fruits. The entire set of data and code of an object can be made a user defined data type with the help of a class. Once a class is defined, any number of objects belonging to that class can be created.

Encapsulation: The wrapping up of data and functions into a single unit (called class) is known as Encapsulation. It hides the implementation details of an object from its users. Encapsulation prevents unauthorized access of data or functionality. The data is not accessible to the outside world, and only functions which are wrapped in the class can access it. This is called data hiding or information hiding.

Data Abstraction: Abstraction refers to the act of representing essential features without including background details or explanations. It separates unnecessary details or explanations so as to reduce complexities of understanding requirements.

Inheritance: Inheritance is the process by which objects of one class acquire the properties of objects of another class. Hierarchical Classification Reusability adding additional features to an existing class without modifying it. That is, deriving a new class from the existing one. The new class will have the combined features of both the classes. New class is also called as Derived class and existing class is called as Base Class.

Polymorphism: (having many forms) Ability to take more than one form. The polymorphism is an ability to access different implementations of a function using the same name. Ex: Function to perform addition operation Input Output Two integer numbers integer sum Two float numbers float sum Two strings constants concatenation

Addition Operation add(int, int) add(float, float) add(string, string)

Operator Overloading: The process of making an operator to exhibit different behaviours in different instances. Function Overloading: Using a single function name to perform different types of tasks.

Dynamic Binding: Dynamic binding (late binding) means that the code associated with a procedure call is not known until the time of the call at run-time. Usually associated with Polymorphism and Inheritance. At run-time, the code matching the object under current reference will be called.

Message Passing: Set of objects communicate with each other. Steps involved: 1. Creating classes that define objects and their behaviour. 2. Creating objects from class definitions. 3. Establishing communication among objects. Objects communicate with one another by sending and receiving information. A message for an object is a request for execution of a procedure, and therefore will invoke a procedure in the receiving object that generates the desired result. Message Passing involves specifying the name of the object, the name of the procedure(message) and the information to be sent.

employee.salary(name); Object Message/ Procedure Information Objects have a life cycle. They can be created and destroyed. Communication with an object is feasible as long as it is alive.

Difference between Procedure Oriented Programming and Object Oriented Programming Procedure Oriented Programming In POP, program is divided into small parts called functions. In POP, Importance is not given to data but to functions as well as sequence of actions to be done. POP follows Top Down approach. POP does not have any access specifier. In POP, Data can move freely from function to function in the system. To add new data and function in POP is not so easy. Object Oriented Programming In OOP, program is divided into parts called objects. In OOP, Importance is given to the data rather than procedures or functions because it works as a real world. OOP follows Bottom Up approach. OOP has access modifiers named Public, Private, Protected, etc. In OOP, objects can move and communicate with each other through member functions. OOP provides an easy way to add new data and function.

Procedure Oriented Programming In POP, Most function uses Global data for sharing that can be accessed freely from function to function in the system. POP does not have any proper way for hiding data so it is less secure. In POP, Overloading is not possible. Example of POP are : C, VB, FORTRAN, Pascal. Object Oriented Programming In OOP, data can not move easily from function to function, it can be kept public or private so we can control the access of data. OOP provides Data Hiding so provides more security. In OOP, overloading is possible in the form of Function Overloading and Operator Overloading. Example of OOP are : C++, JAVA, VB.NET, C#.NET.

References Sourav Sahay, Objected Oriented Programming with C++ E Balagurusamy, Objected Oriented Programming with C++ P. B. Kotur, Objected Oriented Programming with C++