SolutionmandmAnswermGuide:mFarrell, mJavamProgrammingm 10e,m [978-035-767-3423], mChapterm1:mCreatingmJavam Programs
Solution and Answer Guide m m m
Farrell,m JavamProgramming m10e,m [978-035-767-3423],m Chapter m1:mCreating m JavamPrograms
Table of Contents
m m
Reviewm QuestionsmAnswers.......................................................................................................... 1
Programmingm Exercisesm Solutions .............................................................................................. 8
Debuggingm Exercisesm Solutions ................................................................................................. 15
GamemZonem Solutions................................................................................................................. 17
Casem Problemsm Solutions ........................................................................................................... 18
Review Questions Answers
m m
1. Them most m basicm circuitry-levelm computerm languagem ism ____________.
a. machinem language
b. Java
c. high-levelm language
d. C++
Answer:m a
Feedback:m
Them most m basicm circuitry-
levelm computerm languagem ism machinem language.m Machinem language,m orm machinem code,m
ism them most m basicm set m ofm instructionsm am computerm canm execute.m Javam andm C++m arem bot
hm high-levelm languagesm andm arem them oppositem ofm circuitry-levelm computerm language.m
2. Languagesm that m let m youm usem anm easily m understoodm vocabulary m ofm descriptivem terms,m suchm asm r
ead,m write,m orm add,m arem knownm asm ____________languages.
a. procedural
b. high-level
c. machine
d. object-oriented
©m2022 mCengage.mAll mRightsmReserved.mMaymnotmbemscanned,mcopiedmormduplicated,mormpostedmtomampubliclymacces 1
sible mwebsite,m inmwhole morminm part.m
,SolutionmandmAnswermGuide:mFarrell, mJavamProgrammingm 10e,m [978-035-767-3423], mChapterm1:mCreatingmJavam Programs
Answer:m b
Feedback:m
High-levelm languagesm usem English-likem terms;m Javam ism anm examplem ofm am high-
levelm language.m Proceduralm languagesm arem thosem that m runm by m executingm am seriesm ofm pr
oceduresm orm methods.m Machine-levelm languagesm dom not m usem English-
likem terms;m they m usem 1sm andm 0s.m Object-
orientedm languagesm arem runm by m declaringm andm usingm object sm that m containm datam andm m
ethods.
3. Them rulesm ofm am programmingm languagem constitutem itsm ____________.
a. syntax
b. logic
c. format
d. objects
Answer:m a
Feedback:m
Them rulesm ofm am programmingm languagem constitutem itsm syntax.
4. Am ____________m translatesm high-levelm languagem statementsm intom machinem code.
a. programmer
b. syntaxm detector
c. compiler
d. decipherer
Answer:m c
Feedback:m
Am compilerm translatesm high-
levelm languagem statementsm intom machinem code.m Am programmerm writesm high-
levelm languagem statementsm but m doesm not m translatem them.m “Syntaxm detector” m andm “decip
herer” m arem not m termsm usedm inm programming.
5. Namedm computerm memory m locationsm arem calledm ____________.
a. compilers
b. variables
©m2022 mCengage.mAll mRightsmReserved.mMaymnotmbemscanned,mcopiedmormduplicated,mormpostedmtomampubliclymacces 2
sible mwebsite,m inmwhole morminm part.m
,SolutionmandmAnswermGuide:mFarrell, mJavamProgrammingm 10e,m [978-035-767-3423], mChapterm1:mCreatingmJavam Programs
c. addresses
d. appellations
Answer:m b
Feedback:m
Namedm computerm memory m locationsm arem variables.m Compilersm translatem programming
m statementsm intom machinem language;m they m arem not m memory m locations.m Addressesm arem
unnamedm computerm memory m locations.m “Appellations” m ism not m am termm usedm inm program
ming.
6. Them individualm operationsm usedm inm am computerm programm arem oftenm groupedm intom logicalm units
m calledm ____________.
a. procedures
b. variables
c. constants
d. logistics
Answer:m a
Feedback:m
Them individualm operationsm usedm inm am computerm programm arem oftenm groupedm intom logic
alm unitsm calledm procedures.m Variablesm arem namedm memory m locations,m andm constantsm ar
em valuesm that m dom not m change;m they m arem not m groupsm ofm logicalm operations.m “Logistics” m is
m not m am termm commonly m usedm inm programming.
7. Envisioningm programm componentsm asm objectsm that m arem similarm tom concretem objectsm inm them real
m worldm ism them hallmarkm ofm ____________.
a. command-linem operatingm systems
b. proceduralm programming
c. object-orientedm programming
d. machinem languages
Answer:m c
Feedback:m
©m2022 mCengage.mAll mRightsmReserved.mMaymnotmbemscanned,mcopiedmormduplicated,mormpostedmtomampubliclymacces 3
sible mwebsite,m inmwhole morminm part.m
, SolutionmandmAnswermGuide:mFarrell, mJavamProgrammingm 10e,m [978-035-767-3423], mChapterm1:mCreatingmJavam Programs
Envisioningm programm componentsm asm objectsm that m arem similarm tom concretem objectsm inm t
hem realm worldm ism them hallmarkm ofm object-orientedm programming.
8. Them valuesm ofm anm object’sm attributesm arem knownm asm itsm ____________.
a. state
b. orientation
c. methods
d. condition
Answer:m a
Feedback:m
Them valuesm ofm anm object’sm attributesm arem knownm asm itsm state.
9. Anm instancem ofm am classm ism a(n)m ____________.
a. method
b. procedure
c. object
d. case
Answer:m c
Feedback:m
Anm instancem ofm am classm ism anm object.m
10. Javam ism architecturally m ____________.
a. neutral
b. oriented
c. specific
d. abstract
Answer:m a
Feedback:m
Javam ism architecturally m neutral.
©m2022 mCengage.mAll mRightsmReserved.mMaymnotmbemscanned,mcopiedmormduplicated,mormpostedmtomampubliclymacces 4
sible mwebsite,m inmwhole morminm part.m
Solution and Answer Guide m m m
Farrell,m JavamProgramming m10e,m [978-035-767-3423],m Chapter m1:mCreating m JavamPrograms
Table of Contents
m m
Reviewm QuestionsmAnswers.......................................................................................................... 1
Programmingm Exercisesm Solutions .............................................................................................. 8
Debuggingm Exercisesm Solutions ................................................................................................. 15
GamemZonem Solutions................................................................................................................. 17
Casem Problemsm Solutions ........................................................................................................... 18
Review Questions Answers
m m
1. Them most m basicm circuitry-levelm computerm languagem ism ____________.
a. machinem language
b. Java
c. high-levelm language
d. C++
Answer:m a
Feedback:m
Them most m basicm circuitry-
levelm computerm languagem ism machinem language.m Machinem language,m orm machinem code,m
ism them most m basicm set m ofm instructionsm am computerm canm execute.m Javam andm C++m arem bot
hm high-levelm languagesm andm arem them oppositem ofm circuitry-levelm computerm language.m
2. Languagesm that m let m youm usem anm easily m understoodm vocabulary m ofm descriptivem terms,m suchm asm r
ead,m write,m orm add,m arem knownm asm ____________languages.
a. procedural
b. high-level
c. machine
d. object-oriented
©m2022 mCengage.mAll mRightsmReserved.mMaymnotmbemscanned,mcopiedmormduplicated,mormpostedmtomampubliclymacces 1
sible mwebsite,m inmwhole morminm part.m
,SolutionmandmAnswermGuide:mFarrell, mJavamProgrammingm 10e,m [978-035-767-3423], mChapterm1:mCreatingmJavam Programs
Answer:m b
Feedback:m
High-levelm languagesm usem English-likem terms;m Javam ism anm examplem ofm am high-
levelm language.m Proceduralm languagesm arem thosem that m runm by m executingm am seriesm ofm pr
oceduresm orm methods.m Machine-levelm languagesm dom not m usem English-
likem terms;m they m usem 1sm andm 0s.m Object-
orientedm languagesm arem runm by m declaringm andm usingm object sm that m containm datam andm m
ethods.
3. Them rulesm ofm am programmingm languagem constitutem itsm ____________.
a. syntax
b. logic
c. format
d. objects
Answer:m a
Feedback:m
Them rulesm ofm am programmingm languagem constitutem itsm syntax.
4. Am ____________m translatesm high-levelm languagem statementsm intom machinem code.
a. programmer
b. syntaxm detector
c. compiler
d. decipherer
Answer:m c
Feedback:m
Am compilerm translatesm high-
levelm languagem statementsm intom machinem code.m Am programmerm writesm high-
levelm languagem statementsm but m doesm not m translatem them.m “Syntaxm detector” m andm “decip
herer” m arem not m termsm usedm inm programming.
5. Namedm computerm memory m locationsm arem calledm ____________.
a. compilers
b. variables
©m2022 mCengage.mAll mRightsmReserved.mMaymnotmbemscanned,mcopiedmormduplicated,mormpostedmtomampubliclymacces 2
sible mwebsite,m inmwhole morminm part.m
,SolutionmandmAnswermGuide:mFarrell, mJavamProgrammingm 10e,m [978-035-767-3423], mChapterm1:mCreatingmJavam Programs
c. addresses
d. appellations
Answer:m b
Feedback:m
Namedm computerm memory m locationsm arem variables.m Compilersm translatem programming
m statementsm intom machinem language;m they m arem not m memory m locations.m Addressesm arem
unnamedm computerm memory m locations.m “Appellations” m ism not m am termm usedm inm program
ming.
6. Them individualm operationsm usedm inm am computerm programm arem oftenm groupedm intom logicalm units
m calledm ____________.
a. procedures
b. variables
c. constants
d. logistics
Answer:m a
Feedback:m
Them individualm operationsm usedm inm am computerm programm arem oftenm groupedm intom logic
alm unitsm calledm procedures.m Variablesm arem namedm memory m locations,m andm constantsm ar
em valuesm that m dom not m change;m they m arem not m groupsm ofm logicalm operations.m “Logistics” m is
m not m am termm commonly m usedm inm programming.
7. Envisioningm programm componentsm asm objectsm that m arem similarm tom concretem objectsm inm them real
m worldm ism them hallmarkm ofm ____________.
a. command-linem operatingm systems
b. proceduralm programming
c. object-orientedm programming
d. machinem languages
Answer:m c
Feedback:m
©m2022 mCengage.mAll mRightsmReserved.mMaymnotmbemscanned,mcopiedmormduplicated,mormpostedmtomampubliclymacces 3
sible mwebsite,m inmwhole morminm part.m
, SolutionmandmAnswermGuide:mFarrell, mJavamProgrammingm 10e,m [978-035-767-3423], mChapterm1:mCreatingmJavam Programs
Envisioningm programm componentsm asm objectsm that m arem similarm tom concretem objectsm inm t
hem realm worldm ism them hallmarkm ofm object-orientedm programming.
8. Them valuesm ofm anm object’sm attributesm arem knownm asm itsm ____________.
a. state
b. orientation
c. methods
d. condition
Answer:m a
Feedback:m
Them valuesm ofm anm object’sm attributesm arem knownm asm itsm state.
9. Anm instancem ofm am classm ism a(n)m ____________.
a. method
b. procedure
c. object
d. case
Answer:m c
Feedback:m
Anm instancem ofm am classm ism anm object.m
10. Javam ism architecturally m ____________.
a. neutral
b. oriented
c. specific
d. abstract
Answer:m a
Feedback:m
Javam ism architecturally m neutral.
©m2022 mCengage.mAll mRightsmReserved.mMaymnotmbemscanned,mcopiedmormduplicated,mormpostedmtomampubliclymacces 4
sible mwebsite,m inmwhole morminm part.m