SlideShare une entreprise Scribd logo
1  sur  27
Télécharger pour lire hors ligne
Free Ebooks DownloadFree Ebooks Download
Mba EbooksMba Ebooks
By Edhole
Mba ebooks
Free ebooks download
http://ebooks.edhole.com
Object-Oriented ProgrammingObject-Oriented Programming
BasicsBasics
Prof. Ankur Teredesai,
Computer Science Department,
RIT.
http://ebooks.edhole.com
As time goes byAs time goes by
You must remember this,
A kiss is still a kiss,
A sigh is just a sigh,
The fundamental things apply,
As time goes by.
- Herman Huupfeld
“As time goes by”
http://ebooks.edhole.com
Classes and ObjectsClasses and Objects
Class
<CAR>
http://ebooks.edhole.com
ObjectsObjects
 The term object is not easily defined
 According to Webster:
 Object: a visible or tangible thing of
relative stable form; A thing that may be
apprehended intellectually; A thing to
which thought or action is directed
 In this class, we will use the following
definition:
 An object has state, behavior, and identity
(Booch)
http://ebooks.edhole.com
Classes and ObjectsClasses and Objects
Object
<7_series_BMW>
Object
<Ford_Mustang>
Object
<VW_Beetle>
http://ebooks.edhole.com
StateState
 The state of an object
encompasses all of the
(static) properties of the
object plus the current
(dynamic) values of each of
these properties
 A property is an inherent or
distinctive characteristic,
trait, quality, or feature that
contribute to making an
object uniquely that object
 We will use the word
attribute, or data member, to
refer to the state of an object
 State of the object
Ford_Mustang is
THIS COOL
LOOKING RED
Ford_Mustang.
 A property of THIS
Mustang is its Color.
 Attribute is another
name for the
property e.g. color.
http://ebooks.edhole.com
ExamplesExamples
 Properties ( Attributes ) :
 Elevators travel up or down
 Vending machines accept coins
 Clocks indicate the current time
 Values
 Current floor
 Number of coins deposited
 The number of minutes since the last hour
http://ebooks.edhole.com
Messages to ObjectsMessages to Objects
Object
<7_series_BMW>
“Start the
engine of
the BMW”
Start_Engine
http://ebooks.edhole.com
Method of a ClassMethod of a Class
Class
<CAR>
Start_Engine
http://ebooks.edhole.com
BehaviorBehavior
 Behavior is how an object acts and
reacts, in terms of state changes and
interactions with other objects.
 An operation is some action that one
object performs upon another in order
to elicit a reaction.
 We will use the word method to
describe object behavior in java.
 Invoking a method causes the behavior
to take place.
http://ebooks.edhole.com
Types of MethodsTypes of Methods
 There are 4 basic types of methods:
 Modifier (sometimes called a mutator)

Changes the value associated with an attribute of the object

E.g. A method like Change_Car_Color
 Accessor

Returns the value associated with an attribute of the object

E.g. A method like Price_of_Car
 Constructor

Called once when the object is created (before any other
method will be invoked)

E.g. Car(Mustang)
 Destructor

Called when the object is destroyed

E.g.~Car( )
http://ebooks.edhole.com
IdentityIdentity
 Identity is the property of an object that
distinguishes it from all other objects.
 The failure to recognize the difference
between the name of the object and the
object itself is the source of many errors
in object-oriented (OO) programming.
http://ebooks.edhole.com
Assignment and EqualityAssignment and Equality
 What does it mean to assign one object to
another?
 Copy the name only (shallow copy)
 Duplicate the object, creating a different object
(with a different name) whose state and behavior
is the same as the original (deep copy)
 Equality like assignment, can mean two
things
 Two names designate the same object
 Two objects are different but their state and
behavior are the same
http://ebooks.edhole.com
RelationshipsRelationships
 Objects contribute to the behavior of a
system by collaborating with one another
 A car is a collection of parts like the Engine,
Steering Wheel, Wipers,Wheels each sending
messages to each other so that the car can be
driven!!
 The relationship between any two objects
encompasses the assumptions that each
makes about the other, including what
operations can be performed and what
behavior results from it.
http://ebooks.edhole.com
RelationshipsRelationships
 There are two kinds of relationships that
are of particular interest.
 Using relationship

E.g. Owner uses the Car.
 Containing relationship

E.g. Car contains an Engine
http://ebooks.edhole.com
Therefore a Class is?Therefore a Class is?
 According to Webster
 A group, set, or kind marked by common
attributes or a common attribute
 A class is a set of objects that share a
common structure and a common
behavior
 An object is a concrete entity that exists in
space and time, an instance of a class
 A class represents only an abstraction, the
essence of an object from the class
http://ebooks.edhole.com
ClassClass
 A class can be thought of as a cookie cutter,
form which objects can be instantiated
 A class is to an object, as a blueprint is to a
building
 The class mammal represents the
characteristics common to all mammals
 Live birth, nurse young, have hair, …
 “Paul”, “PJ”, “Lisa”, “Heidi”, and “James” are
specific instances from the class mammal
http://ebooks.edhole.com
Class RelationshipsClass Relationships
 Consider for a moment the following
classes
 Flowers
 Daisies
 Red roses
 Yellow roses
 Petals
 What observations can you make?
http://ebooks.edhole.com
Kinds of RelationshipsKinds of Relationships
 Classes, like objects, do not exist in
isolation.
 Relations between classes can be
made for one of two reasons.
 To indicate some sort of sharing.

A yellow rose and a red rose are both roses
and have petals, roots, leaves, thorns, etc.
 Some kind of semantic connection.

Daisies and roses are both flowers that are
pollinated in the same way.
http://ebooks.edhole.com
Kinds of Class RelationshipsKinds of Class Relationships
 There are three basic kinds of class
relationships
 Generalization (“kind of”)

A rose is a kind-of a flower

Generalization provides the ability to create subclasses

Subclasses share the structure of the parent class
 Aggregation (“part of”)

A petal is part-of a rose

Aggregation allows one to construct new classes from
existing one
 Association
http://ebooks.edhole.com
InheritanceInheritance
 The term, inheritance, is used in many
object oriented (OO) programming
languages to describe the
generalization relationship
 Inheritance is a relationship where one
class shares the structure or behavior
defined in one class (single inheritance)
or more (multiple inheritance)
http://ebooks.edhole.com
Types of InheritanceTypes of Inheritance
Form of
Inheritance
Description
Specification The superclass defines behavior that is implemented in the
subclass but not in the superclass. Provides a way to
guarantee that subclass implement the same behavior.
Specialization The subclass is a specialized form of the superclass but
satisfies the specifications of the parent class in all relevant
aspects.
Extension The subclass adds new functionality to the parent
class, but does not change any inherited behavior.
Limitation The subclass restricts the use of some of the behavior
inherited from the superclass.
Combination The subclass inherits features from more than one
superclass (i.e. multiple inheritance).
http://ebooks.edhole.com
Benefits of InheritanceBenefits of Inheritance
 One view of inheritance is that it
provides a way to specify some
properties/behaviors that all subclasses
must exhibit
 Inheritance can be used to re-use code
 Inheritance also provides the ability to
generalize
 A method can be written to work with the
super-class but subclasses can be passed
as arguments
http://ebooks.edhole.com
Views of a ClassViews of a Class
 A class can be viewed as a sort of
contract that specifies what instances of
the class can, and cannot do
 It is possible to distinguish between the
outside and inside view of a class
 The interface of a class provides its
outside view and emphasizes the
abstraction
 The implementation of a class is its
inside view
http://ebooks.edhole.com
AccessAccess
 Most classes provide three levels of access
to their members (state and behavior):
 Public

The part of the class of the class that is visible to all
clients of the class
 Protected

The part of the class that is only visible to subclasses of
the class
 Private

A part of the class that is not visible to any other classes
http://ebooks.edhole.com
Free Ebooks DownloadFree Ebooks Download
Mba EbooksMba Ebooks
By Edhole
Mba ebooks
Free ebooks download
http://ebooks.edhole.com

Contenu connexe

En vedette (14)

Intro to tour 1
Intro to tour 1Intro to tour 1
Intro to tour 1
 
Best impression
Best impressionBest impression
Best impression
 
E learning4
E learning4E learning4
E learning4
 
My trip dublin
My trip dublinMy trip dublin
My trip dublin
 
Presentacion corona
Presentacion coronaPresentacion corona
Presentacion corona
 
Economia x d
Economia x dEconomia x d
Economia x d
 
Grammar translation methods
Grammar translation methodsGrammar translation methods
Grammar translation methods
 
Comercio internacional
Comercio internacionalComercio internacional
Comercio internacional
 
Parenting Apart Presentation
Parenting Apart PresentationParenting Apart Presentation
Parenting Apart Presentation
 
Ec4333 Lecture 1
Ec4333 Lecture 1Ec4333 Lecture 1
Ec4333 Lecture 1
 
Articulo sobre tatuajes
Articulo sobre tatuajesArticulo sobre tatuajes
Articulo sobre tatuajes
 
QLDA - Nhom 1 - BDHung
QLDA - Nhom 1 - BDHungQLDA - Nhom 1 - BDHung
QLDA - Nhom 1 - BDHung
 
Modelo slide Lanac
Modelo slide LanacModelo slide Lanac
Modelo slide Lanac
 
Accountancy in ireland
Accountancy in irelandAccountancy in ireland
Accountancy in ireland
 

Plus de Edhole.com

Chartered accountant in dwarka
Chartered accountant in dwarkaChartered accountant in dwarka
Chartered accountant in dwarkaEdhole.com
 
Ca firm in dwarka
Ca firm in dwarkaCa firm in dwarka
Ca firm in dwarkaEdhole.com
 
Website development company surat
Website development company suratWebsite development company surat
Website development company suratEdhole.com
 
Website designing company in surat
Website designing company in suratWebsite designing company in surat
Website designing company in suratEdhole.com
 
Website dsigning company in india
Website dsigning company in indiaWebsite dsigning company in india
Website dsigning company in indiaEdhole.com
 
Website designing company in delhi
Website designing company in delhiWebsite designing company in delhi
Website designing company in delhiEdhole.com
 
Chartered accountant in dwarka
Chartered accountant in dwarkaChartered accountant in dwarka
Chartered accountant in dwarkaEdhole.com
 
Ca firm in dwarka
Ca firm in dwarkaCa firm in dwarka
Ca firm in dwarkaEdhole.com
 
Website development company surat
Website development company suratWebsite development company surat
Website development company suratEdhole.com
 
Website designing company in surat
Website designing company in suratWebsite designing company in surat
Website designing company in suratEdhole.com
 
Website designing company in india
Website designing company in indiaWebsite designing company in india
Website designing company in indiaEdhole.com
 
Website designing company in delhi
Website designing company in delhiWebsite designing company in delhi
Website designing company in delhiEdhole.com
 
Website designing company in mumbai
Website designing company in mumbaiWebsite designing company in mumbai
Website designing company in mumbaiEdhole.com
 
Website development company surat
Website development company suratWebsite development company surat
Website development company suratEdhole.com
 
Website desinging company in surat
Website desinging company in suratWebsite desinging company in surat
Website desinging company in suratEdhole.com
 
Website designing company in india
Website designing company in indiaWebsite designing company in india
Website designing company in indiaEdhole.com
 

Plus de Edhole.com (20)

Ca in patna
Ca in patnaCa in patna
Ca in patna
 
Chartered accountant in dwarka
Chartered accountant in dwarkaChartered accountant in dwarka
Chartered accountant in dwarka
 
Ca in dwarka
Ca in dwarkaCa in dwarka
Ca in dwarka
 
Ca firm in dwarka
Ca firm in dwarkaCa firm in dwarka
Ca firm in dwarka
 
Website development company surat
Website development company suratWebsite development company surat
Website development company surat
 
Website designing company in surat
Website designing company in suratWebsite designing company in surat
Website designing company in surat
 
Website dsigning company in india
Website dsigning company in indiaWebsite dsigning company in india
Website dsigning company in india
 
Website designing company in delhi
Website designing company in delhiWebsite designing company in delhi
Website designing company in delhi
 
Ca in patna
Ca in patnaCa in patna
Ca in patna
 
Chartered accountant in dwarka
Chartered accountant in dwarkaChartered accountant in dwarka
Chartered accountant in dwarka
 
Ca firm in dwarka
Ca firm in dwarkaCa firm in dwarka
Ca firm in dwarka
 
Ca in dwarka
Ca in dwarkaCa in dwarka
Ca in dwarka
 
Website development company surat
Website development company suratWebsite development company surat
Website development company surat
 
Website designing company in surat
Website designing company in suratWebsite designing company in surat
Website designing company in surat
 
Website designing company in india
Website designing company in indiaWebsite designing company in india
Website designing company in india
 
Website designing company in delhi
Website designing company in delhiWebsite designing company in delhi
Website designing company in delhi
 
Website designing company in mumbai
Website designing company in mumbaiWebsite designing company in mumbai
Website designing company in mumbai
 
Website development company surat
Website development company suratWebsite development company surat
Website development company surat
 
Website desinging company in surat
Website desinging company in suratWebsite desinging company in surat
Website desinging company in surat
 
Website designing company in india
Website designing company in indiaWebsite designing company in india
Website designing company in india
 

Dernier

Sulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesSulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesVijayaLaxmi84
 
Indexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfIndexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfChristalin Nelson
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDhatriParmar
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxSayali Powar
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptxmary850239
 
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQ-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQuiz Club NITW
 
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvRicaMaeCastro1
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...Nguyen Thanh Tu Collection
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationdeepaannamalai16
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptshraddhaparab530
 
An Overview of the Calendar App in Odoo 17 ERP
An Overview of the Calendar App in Odoo 17 ERPAn Overview of the Calendar App in Odoo 17 ERP
An Overview of the Calendar App in Odoo 17 ERPCeline George
 
How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17Celine George
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...Nguyen Thanh Tu Collection
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseCeline George
 
Objectives n learning outcoms - MD 20240404.pptx
Objectives n learning outcoms - MD 20240404.pptxObjectives n learning outcoms - MD 20240404.pptx
Objectives n learning outcoms - MD 20240404.pptxMadhavi Dharankar
 
4.9.24 Social Capital and Social Exclusion.pptx
4.9.24 Social Capital and Social Exclusion.pptx4.9.24 Social Capital and Social Exclusion.pptx
4.9.24 Social Capital and Social Exclusion.pptxmary850239
 
6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroom6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroomSamsung Business USA
 

Dernier (20)

Sulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesSulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their uses
 
prashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Professionprashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Profession
 
Indexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfIndexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdf
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx
 
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQ-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
 
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentation
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.ppt
 
Paradigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTAParadigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTA
 
An Overview of the Calendar App in Odoo 17 ERP
An Overview of the Calendar App in Odoo 17 ERPAn Overview of the Calendar App in Odoo 17 ERP
An Overview of the Calendar App in Odoo 17 ERP
 
How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17How to Fix XML SyntaxError in Odoo the 17
How to Fix XML SyntaxError in Odoo the 17
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...
 
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of EngineeringFaculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 Database
 
Objectives n learning outcoms - MD 20240404.pptx
Objectives n learning outcoms - MD 20240404.pptxObjectives n learning outcoms - MD 20240404.pptx
Objectives n learning outcoms - MD 20240404.pptx
 
4.9.24 Social Capital and Social Exclusion.pptx
4.9.24 Social Capital and Social Exclusion.pptx4.9.24 Social Capital and Social Exclusion.pptx
4.9.24 Social Capital and Social Exclusion.pptx
 
6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroom6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroom
 

Mba Ebooks ! Edhole

  • 1. Free Ebooks DownloadFree Ebooks Download Mba EbooksMba Ebooks By Edhole Mba ebooks Free ebooks download http://ebooks.edhole.com
  • 2. Object-Oriented ProgrammingObject-Oriented Programming BasicsBasics Prof. Ankur Teredesai, Computer Science Department, RIT. http://ebooks.edhole.com
  • 3. As time goes byAs time goes by You must remember this, A kiss is still a kiss, A sigh is just a sigh, The fundamental things apply, As time goes by. - Herman Huupfeld “As time goes by” http://ebooks.edhole.com
  • 4. Classes and ObjectsClasses and Objects Class <CAR> http://ebooks.edhole.com
  • 5. ObjectsObjects  The term object is not easily defined  According to Webster:  Object: a visible or tangible thing of relative stable form; A thing that may be apprehended intellectually; A thing to which thought or action is directed  In this class, we will use the following definition:  An object has state, behavior, and identity (Booch) http://ebooks.edhole.com
  • 6. Classes and ObjectsClasses and Objects Object <7_series_BMW> Object <Ford_Mustang> Object <VW_Beetle> http://ebooks.edhole.com
  • 7. StateState  The state of an object encompasses all of the (static) properties of the object plus the current (dynamic) values of each of these properties  A property is an inherent or distinctive characteristic, trait, quality, or feature that contribute to making an object uniquely that object  We will use the word attribute, or data member, to refer to the state of an object  State of the object Ford_Mustang is THIS COOL LOOKING RED Ford_Mustang.  A property of THIS Mustang is its Color.  Attribute is another name for the property e.g. color. http://ebooks.edhole.com
  • 8. ExamplesExamples  Properties ( Attributes ) :  Elevators travel up or down  Vending machines accept coins  Clocks indicate the current time  Values  Current floor  Number of coins deposited  The number of minutes since the last hour http://ebooks.edhole.com
  • 9. Messages to ObjectsMessages to Objects Object <7_series_BMW> “Start the engine of the BMW” Start_Engine http://ebooks.edhole.com
  • 10. Method of a ClassMethod of a Class Class <CAR> Start_Engine http://ebooks.edhole.com
  • 11. BehaviorBehavior  Behavior is how an object acts and reacts, in terms of state changes and interactions with other objects.  An operation is some action that one object performs upon another in order to elicit a reaction.  We will use the word method to describe object behavior in java.  Invoking a method causes the behavior to take place. http://ebooks.edhole.com
  • 12. Types of MethodsTypes of Methods  There are 4 basic types of methods:  Modifier (sometimes called a mutator)  Changes the value associated with an attribute of the object  E.g. A method like Change_Car_Color  Accessor  Returns the value associated with an attribute of the object  E.g. A method like Price_of_Car  Constructor  Called once when the object is created (before any other method will be invoked)  E.g. Car(Mustang)  Destructor  Called when the object is destroyed  E.g.~Car( ) http://ebooks.edhole.com
  • 13. IdentityIdentity  Identity is the property of an object that distinguishes it from all other objects.  The failure to recognize the difference between the name of the object and the object itself is the source of many errors in object-oriented (OO) programming. http://ebooks.edhole.com
  • 14. Assignment and EqualityAssignment and Equality  What does it mean to assign one object to another?  Copy the name only (shallow copy)  Duplicate the object, creating a different object (with a different name) whose state and behavior is the same as the original (deep copy)  Equality like assignment, can mean two things  Two names designate the same object  Two objects are different but their state and behavior are the same http://ebooks.edhole.com
  • 15. RelationshipsRelationships  Objects contribute to the behavior of a system by collaborating with one another  A car is a collection of parts like the Engine, Steering Wheel, Wipers,Wheels each sending messages to each other so that the car can be driven!!  The relationship between any two objects encompasses the assumptions that each makes about the other, including what operations can be performed and what behavior results from it. http://ebooks.edhole.com
  • 16. RelationshipsRelationships  There are two kinds of relationships that are of particular interest.  Using relationship  E.g. Owner uses the Car.  Containing relationship  E.g. Car contains an Engine http://ebooks.edhole.com
  • 17. Therefore a Class is?Therefore a Class is?  According to Webster  A group, set, or kind marked by common attributes or a common attribute  A class is a set of objects that share a common structure and a common behavior  An object is a concrete entity that exists in space and time, an instance of a class  A class represents only an abstraction, the essence of an object from the class http://ebooks.edhole.com
  • 18. ClassClass  A class can be thought of as a cookie cutter, form which objects can be instantiated  A class is to an object, as a blueprint is to a building  The class mammal represents the characteristics common to all mammals  Live birth, nurse young, have hair, …  “Paul”, “PJ”, “Lisa”, “Heidi”, and “James” are specific instances from the class mammal http://ebooks.edhole.com
  • 19. Class RelationshipsClass Relationships  Consider for a moment the following classes  Flowers  Daisies  Red roses  Yellow roses  Petals  What observations can you make? http://ebooks.edhole.com
  • 20. Kinds of RelationshipsKinds of Relationships  Classes, like objects, do not exist in isolation.  Relations between classes can be made for one of two reasons.  To indicate some sort of sharing.  A yellow rose and a red rose are both roses and have petals, roots, leaves, thorns, etc.  Some kind of semantic connection.  Daisies and roses are both flowers that are pollinated in the same way. http://ebooks.edhole.com
  • 21. Kinds of Class RelationshipsKinds of Class Relationships  There are three basic kinds of class relationships  Generalization (“kind of”)  A rose is a kind-of a flower  Generalization provides the ability to create subclasses  Subclasses share the structure of the parent class  Aggregation (“part of”)  A petal is part-of a rose  Aggregation allows one to construct new classes from existing one  Association http://ebooks.edhole.com
  • 22. InheritanceInheritance  The term, inheritance, is used in many object oriented (OO) programming languages to describe the generalization relationship  Inheritance is a relationship where one class shares the structure or behavior defined in one class (single inheritance) or more (multiple inheritance) http://ebooks.edhole.com
  • 23. Types of InheritanceTypes of Inheritance Form of Inheritance Description Specification The superclass defines behavior that is implemented in the subclass but not in the superclass. Provides a way to guarantee that subclass implement the same behavior. Specialization The subclass is a specialized form of the superclass but satisfies the specifications of the parent class in all relevant aspects. Extension The subclass adds new functionality to the parent class, but does not change any inherited behavior. Limitation The subclass restricts the use of some of the behavior inherited from the superclass. Combination The subclass inherits features from more than one superclass (i.e. multiple inheritance). http://ebooks.edhole.com
  • 24. Benefits of InheritanceBenefits of Inheritance  One view of inheritance is that it provides a way to specify some properties/behaviors that all subclasses must exhibit  Inheritance can be used to re-use code  Inheritance also provides the ability to generalize  A method can be written to work with the super-class but subclasses can be passed as arguments http://ebooks.edhole.com
  • 25. Views of a ClassViews of a Class  A class can be viewed as a sort of contract that specifies what instances of the class can, and cannot do  It is possible to distinguish between the outside and inside view of a class  The interface of a class provides its outside view and emphasizes the abstraction  The implementation of a class is its inside view http://ebooks.edhole.com
  • 26. AccessAccess  Most classes provide three levels of access to their members (state and behavior):  Public  The part of the class of the class that is visible to all clients of the class  Protected  The part of the class that is only visible to subclasses of the class  Private  A part of the class that is not visible to any other classes http://ebooks.edhole.com
  • 27. Free Ebooks DownloadFree Ebooks Download Mba EbooksMba Ebooks By Edhole Mba ebooks Free ebooks download http://ebooks.edhole.com