Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4,6 TrustPilot
logo-home
Document preview thumbnail
Preview 4 out of 96 pages
Exam (elaborations)

Solution Manual For Concepts of Programming Languages 11th Edition by Robert Sebesta

Document preview thumbnail
Preview 4 out of 96 pages

Solution Manual For Concepts of Programming Languages 11th Edition by Robert Sebesta

Content preview

Object-Orientedg Programmingg (CSC221)
Introduction

Whatg isg OOP
• Ing simpleg term,g OOPg isg programmingg withg objects.
• Objects
o Objectsg areg theg evolutionaryg extensiong ofg theg conceptg ofg recordsg thatge
nablegusgtogorganizegdatagintogpackages.
o Itg allowg usg tog combineg bothg datag andg codeg intog ag singleg package.
o Therefore,g ang objectg isg ag languageg constructg thatg tiesg datag withg theg functionsg
thatgoperatesgongthegdata.


OOPg viewpoint

Lowglevelg object




Windowg object FilegManagement
gobject




Wordgprocessing Editinggobject
gApplication




Keyboardgcontrol
gobject




Theg figureg aboveg showg howg tog createg ag setg ofg objectsg forg ag wordg processorg application.

• Theg arrangementg isg dividedg intog objectsg suchg asg lowg levelg object,g windowg
object,gfilegmanagementgobjectsgetc.


Advantages
- Majorg operationg ofg ag programg cang easilyg beg isolated.
- Someg objectsg areg usedg tog createg otherg objects.
- Thisg helpsg tog hideg theg detailsg ofg theg lowerg levelg objects.


Traditional programming vs OOP
g g g

- Ing traditionalg view,g functionsg areg theg mostg important,g i.e.g allg theg codeg ing ag programg i
sgdesignedgaroundgthegfunctions.
- Ing theg OOPg view,g objectsg areg theg mostg important,g programsg areg designedg aroundg objects,
gfunctionsgaregsecondary




7

,- Thisgrolegrevealsgingthegwaygobjectsgaregused,grathergthangpassinggobjects(data)gtogfun
ctions,gobjectsgaregusedgtogcallgfunctions.
- Programsgcangavoidglargegfunctionsgthatgcontainglogicgforgmultiplegcases,ginsteadgmulti
plegobjectsgaregcreatedgtogrepresentgthegdifferentglogicalgcomponentsgofgagprogram.

Componentsg ofg OOP
• Classes
• Objects
• Instanceg variables
• Methods


Classes and objects
g g




- Ag classg isg ang abstractg definitiong ofg ang object
o Itg definesg theg structureg andg behaviourg ofg eachg objectg ing theg class.
o Itg servesg asg ag templateg forg creatingg objects

- objectsg mayg beg groupedg intog classes
o Ag particularg objectg ofg ag classg isg ang instance.

- Theg figureg belowg illustrate:



Classg =g typegdefinitiongObj
ectg=gvariablegofgagclass.

1.exe




- Ag classg containg twog typesg ofg components
o Instanceg variables
o g Methods
1.exe




- Instanceg variablesg defineg theg internalg datag stateg ofg ang object
- Methodsg defineg ang object‟sg behavior,g thatg isg theg actionsg thatg theg objectg can
perform.

Sampleg class

• Class

Properties Course Behaviour

Name Addg ag student
Location Deleteg ag student
Daysg offered Getg courseg roster
Creditg hours ….
Startg time e.t.c




8

,Endg time



Theg threeg faces(properties)g ofg OOP

WhengprogramminggwithgC++g„sgobjectgorientedg features,g thereg areg threeg underlyinggp
ropertiesgthatgsurfacegagaingandgagain:
• Encapsulation
• Polymorphism
• Inheritance

Encapsulation
- Encapsulationg isg thegtechniqueg ofg combiningg datag andg theg operationsg neededg tog
processgthegdatagundergonegpackage[object].
- Itg isg whatg givesg objectsg theirg buildingg blockg flavor.
- Encapsulationg providesg twog importantg features:
o Putsg datag andg functionsg underg oneg roof.
o Providesg datag hidingg capabilities.




Polymorphism
- Polymorphismgisg theg qualitygthatgallowsg oneg nameg togbeg usedg forgtwogorgmoreg relatedg butg
technicallygdifferentgpurposes.

- Polymorphismg allowsg oneg nameg tog specifyg ag generalg classg ofg actions.g Withing ag general
gclassg ofg actions,g theg specificg actiongtog beg appliedg isgdeterminedg byg theg typeg ofg data.

Forgexample,gingC,gthegabsolutegvaluegactiongrequiresgthreegdistinctgfunctiongnames:gabs(g)gforginteger,glabs(g)gf
orglongginteger,gandgfabs(g)g forgfloating-
pointgvalue.gHowevergingC++,geachgfunctiongcangbegcalledgbygthegsamegname,gsuchgasgabs(g).gThegtypegofgdatag
usedgtogcallgthegfunctiongdeterminesgwhichgspecificgversiongofgthegfunctiongisgactuallygexecuted.

-
Ing C++g itg isg possibleg tog useg oneg functiong nameg forg manyg differentg purposes.g Thisg typ
eg ofgpolymorphismgisgcalledgfunctiongoverloading.

- Polymorphismgcangalsogbegappliedgtogoperators.gIngthatgcasegitgisgcalledgoperatorgoverloading.
- Theg abilityg tog hideg manyg differentg implementationsg behindg ag singleg interface.


Whatg isg ang interface?
- Ag namedg setg ofg operationsg thatg characterizeg theg behaviourg ofg ang element.
• Theg interfaceg formalizesg polymorphism

<<interface>>
Triangle
gPolygon

, 9

draw
Square

Connected book
 image
Publisher: 2015 ISBN: 9780133943023 Edition: Unknown

Document information

Uploaded on
February 26, 2025
Number of pages
96
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$21.49

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
GOLDENNTESTBANKS
4.7
(720)
Sold
13
Followers
1
Items
460
Last sold
3 months ago


Reviews from verified buyers




Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can immediately select a different document that better matches what you need.

Pay how you prefer, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card or EFT and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions