object oriented concept
TRANSCRIPT
![Page 1: Object Oriented Concept](https://reader030.vdocuments.us/reader030/viewer/2022032616/55a5e4401a28ab37368b4799/html5/thumbnails/1.jpg)
By D .Nayanathara (BSc in MIS)
Object Oriented Concept
![Page 2: Object Oriented Concept](https://reader030.vdocuments.us/reader030/viewer/2022032616/55a5e4401a28ab37368b4799/html5/thumbnails/2.jpg)
• What is OOP
• What is a Class & a Object
• What is Method
• Principles of OOP
• Abstraction
• Inheritance
• Encapsulation
• Polymorphism
Content
![Page 3: Object Oriented Concept](https://reader030.vdocuments.us/reader030/viewer/2022032616/55a5e4401a28ab37368b4799/html5/thumbnails/3.jpg)
• OOP promote the component based approached to software development.
• Implementation details are hidden within the class
• Encapsulate data (attributes) and functions(behavior) into packages called classes . Class are re-useable
• Can add new functionally to program with out affection others functions.
• Ex: Java , C++
What is OOP
![Page 4: Object Oriented Concept](https://reader030.vdocuments.us/reader030/viewer/2022032616/55a5e4401a28ab37368b4799/html5/thumbnails/4.jpg)
• Class is like a blueprint , provide the characteristic of an object • Ex : Car Class
Class
Car
YearNameModelColorNumber of doors
start()stop()changeGears()accelerate()decelerate()turn()break()
Attributes/Properties
Behaviors/Methods
Class Name
House Plan
![Page 5: Object Oriented Concept](https://reader030.vdocuments.us/reader030/viewer/2022032616/55a5e4401a28ab37368b4799/html5/thumbnails/5.jpg)
• Instantiation of the class (objects are create from the class)
• Also called as Instance
• Object is a collection of data based on structure of the class
• One class can create multiple objects• Ex : Built the house according to blueprint
Create Object Using Car Class
Object
myAudiA3 : Car
Year = “2007”Name = “AudiA3”Model = “A3Diesel”Color = “Black”Number of doors = “4”
Object Name Class Name
![Page 6: Object Oriented Concept](https://reader030.vdocuments.us/reader030/viewer/2022032616/55a5e4401a28ab37368b4799/html5/thumbnails/6.jpg)
• Method describes the behavior of an object
• Within a program, a method usually affect only one particular object
• Ex : Accelerate() method in car class• Every car can accelerate but Program
only need to call method Accelerate()
Method
myAudiA3 : Car
Year = “2007”Name = “AudiA3”Model = “A3Diesel”Color = “Black”Number of doors = “4”
start()stop()changeGears()
accelerate()decelerate()turn()break()
![Page 7: Object Oriented Concept](https://reader030.vdocuments.us/reader030/viewer/2022032616/55a5e4401a28ab37368b4799/html5/thumbnails/7.jpg)
• Data Abstraction• Defining a data type and Execute abstract(specific) actions
• Inheritance• Inherits attributes and behaviors from the parent class to its subclass
• Encapsulation• Hide the operation of the object • An object hides what it does from other object and from outside world
• Polymorphism• Poly : many , Morphism : Forms • Ability for data to be processed in more than one form
Principles of OOP
![Page 8: Object Oriented Concept](https://reader030.vdocuments.us/reader030/viewer/2022032616/55a5e4401a28ab37368b4799/html5/thumbnails/8.jpg)
• Provide only the essential details and hide their implementation details from the clients of the class
• Ex : Working with something we know ,how to use without knowing how it works internally.
• Car
• Phone
• TV
Data Abstraction
Call Button
![Page 9: Object Oriented Concept](https://reader030.vdocuments.us/reader030/viewer/2022032616/55a5e4401a28ab37368b4799/html5/thumbnails/9.jpg)
• Inherits attributes and behaviors from the parent class to its subclass
• Sub Class can also include its own attributes and behaviors.
• Mainly used for code reusability
• Derived Class has all the attributes and behaviors of the Base Class• Ex: Car Class
Inheritance
Derived Class/ Sub ClassParent Class/Base Class /
Super Class Derived
![Page 10: Object Oriented Concept](https://reader030.vdocuments.us/reader030/viewer/2022032616/55a5e4401a28ab37368b4799/html5/thumbnails/10.jpg)
Ex : Car Class
Inheritance Cont.
Car
YearNameModelColorNumber of doors
start()stop()changeGears()accelerate()decelerate()turn()break()
audiA4Car
..Model = A4
…accelerate()….
audiA6Car
…Model = A6
…accelerate()….
audiA3Car
…..Model = A3
…accelerate()….
![Page 11: Object Oriented Concept](https://reader030.vdocuments.us/reader030/viewer/2022032616/55a5e4401a28ab37368b4799/html5/thumbnails/11.jpg)
• The process of bundling data and functions together and hide the object implementation details from other object and from outside world.
• Protect the integrity of the object by preventing changes done by users to the internal data of a object , provides safety and ensure system robustness .Ex : Bank Account Class • Ex :
• Encapsulation hides the internal state of the object from others and it conceals the details
• Accelerate method defines how accelerate occurs
• How Burns the fuel
• Generate Electricity etc. .
• When driving a car drive doesn’t need to knows the technical details about how accelerate has done
• When driving a car drive doesn’t need to knows the technical details
Encapsulation – Information hiding
![Page 12: Object Oriented Concept](https://reader030.vdocuments.us/reader030/viewer/2022032616/55a5e4401a28ab37368b4799/html5/thumbnails/12.jpg)
• Poly : many , Morphism : Forms
• Ability for data to be processed in more than one form
• A Single function can used to handle different number and different type of arguments
• Ex : Break method in Car class
• Draw method in Shape Class
Polymorphism
![Page 13: Object Oriented Concept](https://reader030.vdocuments.us/reader030/viewer/2022032616/55a5e4401a28ab37368b4799/html5/thumbnails/13.jpg)
Ex : Car Class
Polymorphism Cont ..
Car
…..
…..break()…..
audiA4Car
…..
…break()….
audiA6Car
…..
…break()….
audiA3Car
…..
…break()….
• Classes “audiA3Car” , “audiA6Car” and “audiA4Car” inherited the method called break() from the Car class(parent class)
• Each class produced different results after executing break method• Ex : “audiA3Car” may brake the rate 000 feet per second , Whereas “audiA6Car”
may brake the rate 111 feet per second …
![Page 14: Object Oriented Concept](https://reader030.vdocuments.us/reader030/viewer/2022032616/55a5e4401a28ab37368b4799/html5/thumbnails/14.jpg)
Ex : Draw method in Shape Class
Polymorphism Cont ..
Shape
draw()
Shape
draw(box)
Shape
draw(circle)
Shape
draw(triangle)
![Page 15: Object Oriented Concept](https://reader030.vdocuments.us/reader030/viewer/2022032616/55a5e4401a28ab37368b4799/html5/thumbnails/15.jpg)