23
ARYA COLLEGE OF ENGINEERING & I.T. Object Oriented Concept Submitted by: Dhiraj Kumar Class: ECE-A Roll no. : 12EAREC052 Submitted to: Dr. Kirti Vyas

power poitnt of oops

Embed Size (px)

Citation preview

ARYA COLLEGE OF ENGINEERING & I.T.

Object Oriented Concept

Submitted by: Dhiraj KumarClass: ECE-ARoll no. : 12EAREC052

Submitted to: Dr. Kirti Vyas

Introduction :

We can define “object oriented programing as an approach that provides a way of modularizing programs by creating partitioned memory area for both data and functions that can be used as a template for creating copies of such modules on demand”.

OOP Concepts• Class.• Object.• Instance.• State.• Method.• Encapsulation.• Inheritance.• Polymorphism.

Class

• A class is an abstract definition of an object.• Defines how would the object look like when created.• The object type.• Think of classes like the patents of actual inventions.

OO Concepts - Abdalla Mahmoud

Classes

Car Human

OO Concepts - Abdalla Mahmoud

Classes2

ManSuzuki

WomanBMW

Object

• An object is the actual entity instance lives in memory and capable of doing real operations.

• Created (instantiated) according to the abstract definition of a class.

• Think of objects like some invention created according to some patent.

OO Concepts - Abdalla Mahmoud

Objects

Object and Their Interaction

Program

Object and Their Interaction

Program

Tom, hold your sweep!

Object and Their Interaction

Program

Tom, hold your sweep!

Tom, beat jerry!

Object and Their Interaction

Program

Tom.holdYourSweep()

Tom.BeatJerry()

IN PROGRAMMING

Object and Their Interaction

Program

Tom.holdYourSweep()

Tom.BeatJerry()

IN PROGRAMMING

message

Object and Their Interaction

Program

Tom.holdYourSweep()

Tom.BeatJerry()

IN PROGRAMMING

message

message

Object vs. Class

• Object

• Class

State• The value of an attribute (variable) of the object.• Describes some object’s characteristics.• Ex: Car.color = red• Adjectives.

Method

• An object’s ability to do some operation.• Implements some functionality.• Invoked by the same object or other interacting objects in the

system.• Ex: car.accelerate()• Verbs.

Message Passing

• The process by which an object:– Sends data to another object.– Asks the other object to invoke a

method.• In other words, objects talk to each others

via messages.

Encapsulation

• Packaging an object's variables within the protective custody of its methods is called encapsulation.

• Often, for practical reasons, an object may wish to expose some of its variables or hide some of its methods.

• Access Levels:

Inheritance• A class inherits state and behavior from its superclass.

Inheritance provides a powerful and natural mechanism for organizing and structuring software programs.

Super Class

Subclasses

OO Concepts - Abdalla Mahmoud

Abstraction & Inheritance

Man

Suzuki

WomanBMW

Car Human

Polymorphism

• Different objects share the same interface (e.g: same method names).

• Different functionalities /implementations.• One object may have several interfaces.• One object can be treated as if it’s an instance from several

types (classes).