g g g g g g g g g g g
ures through Data Structures 3rd Edition Gaddis
g g g g g g
StartinggOutgwithgJava:gFromgControlgStructuresgthroughgDatagStructuresg3eg(GaddisgandgMuganda)gCha
pterg2g JavagFundamentals
2.1 MultiplegChoicegQuestions
1) WhichgonegofgthegfollowinggwouldgcontaingthegtranslatedgJavagbytegcodegforgagprogramgnamedgDemo?
A) Demo.java
B) Demo.code
C) Demo.class
D) Demo.byte
Answer:g C
2) TogcompilegagprogramgnamedgFirst,gusegthegfollowinggcommand:
A) javagFirst.java
B) javacgFirst
C) javacgFirst.java
D) compilegFirst.javac
Answer:g C
3) AgJavagprogramgmustghavegatgleastgonegofgthese:
A) Classgdefinition
B) Variable
C) Comment
D) System.out.println();gstatementg
Answer:g A
4) IngJava,gthegbeginninggofgagcommentgisgmarkedgwith:
A) //
B) ""
C) ;
D) #
Answer:g A
5) Thegtermg typicallygrefersgtogthegdevicegthatgdisplaysgconsolegoutput.
A) standardgoutputgdevice
B) centralgprocessinggunit
C) secondarygstoragegdevice
D) liquidgcrystalgdisplay
gAnswer:g A
6) IngJava,g mustgbegdeclaredgbeforegtheygcangbegused.
A) variables
B) literals
C) keygwords
D) comments
gAnswer:g A
1
Copyrightg©g2016gPearsongEducation,gInc.
mynursytest.store
, DOWNLOAD THE Test Bank for Starting Out with Java From Control Struct
g g g g g g g g g g g
ures through Data Structures 3rd Edition Gaddis
g g g g g g
7) IfgthegfollowinggJavagstatementsgaregexecuted,gwhatgwillgbegdisplayed?
System.out.println("Thegtopgthreegwinnersgare\n");gSystem.out.pr
int("Jody,gthegGiant\n");gSystem.out.print("Buffy,gthegBarbarian
");gSystem.out.println("Adelle,gthegAlligator");
A) Thegtopgthreegwinnersgare
gJody,gthegGiant
Buffy,gthegBarbariangAde
lle,gthegAlligator
B) Thegtopgthreegwinnersgare
Jody,gthegGiant\nBuffy,gthegBarbarianAdelle,gthegAlligator
C) ThegtopgthreegwinnersgaregJody,gthegGiant\nBuffy,gthegBarbarianAdelle,gandgthegAlbino
D) Thegtopgthreegwinnersgare
gJody,gthegGiant
Buffy,gthegBarbarianAdelle,gthegAlligatorgAns
wer:g D
8) Thisgisgagvaluegthatgisgwrittengintogthegcodegofgagprogram.
A) literal
B) assignmentg statement
C) variable
D) operator
gAnswer:g
A
9) Whengtheg+goperatorgisgusedgwithgstrings,gitgisgknowngasgthe:
A) Assignmentg operator
B) Stringgconcatenationgoperator
C) Additiongoperator
D) Combinedgassignmentgoperator
gAnswer:g B
10) Whatgwouldgbegprintedgoutgasgagresultgofgthegfollowinggcode?
System.out.println("Thegquickgbrowngfox"g+
"jumpedgovergtheg\n"g"slowg
movingghen.");
A) Thegquickgbrowngfoxgjumpedgovergtheg\nslowgmovingghen.
B) Thegquickgbrowngfoxgjumpedgovergthe
gslowgmovingghen.
C) Thegquickgbrowngfox
gjumpedgovergthe
slowgmovingghen.
D) Nothing.gThisgisgangerror.
gAnswer:g D
2
Copyrightg©g2016gPearsongEducation,gInc.
mynursytest.store