1. Test:Java FundamentalsFinal Exam
Reviewyouranswers,feedback,andquestionscoresbelow.Anasterisk(*) indicatesacorrect
answer.
Section4
(Answerall questionsinthissection)
1. In Eclipse,whenyouruna Java Application,where maythe resultsdisplay? Mark forReview
(1) Points
Editor Window
Console View (*)
DebugView
Task List
None of the above
Correct
2. What are the Eclipse EditorAreaand Viewsusedfor? Mark for Review (1) Points
(Choose all correctanswers)
To modifyelements.(*)
To navigate ahierarchyof information.(*)
To choose the file systemlocationtodelete afile.
Correct
3. A combinationof viewsandeditorsare referredtoas_______________. Mark forReview
(1) Points
A workspace
A physical location
A perspective (*)
All of the above
Correct
2. 4. In the image below,identifythe components.
Mark for Review(1) Points
A-MainMethod,B-Class,C-Package
A-Class,B-MainMethod,C-Package
A-Package,B-MainMethod,C-Class(*)
None of the above
Correct
5. A counterusedina For loopcannotbe initializedwithinthe Forloopheader.True orfalse?
Mark forReview(1) Points
True
False (*)
Correct
Page 1 of 10 Next Summary
3. Test:Java FundamentalsFinal Exam
Reviewyouranswers,feedback,andquestion scoresbelow.Anasterisk(*) indicatesacorrect
answer.
Section4
(Answerall questionsinthissection)
6. In the code fragmentbelow,the syntax forthe forloop'sinitializationiscorrect.True or false?
publicclassForLoop{
publicstaticvoidmain(Stringargs[])
{
for ((int1=10) (i<20) (i++))<
{System.out.Println("i:"+i);}
}
}
Mark for Review(1) Points
True
False (*)
Correct
7. When importinganotherpackage intoaclassyou mustimportonlythe package classesthatwill
be calledandnot the entire package.True or false? Mark for Review (1) Points
True
False (*)
Correct
8. Which of the twodiagramsbelowillustrate the correctsyntax forvariablesusedinanif-else
statement? Mark forReview(1) Points
4. Example A (*)
Example B
Correct
9. What are Java's simple types? Mark for Review (1) Points
boolean,byte,char,double,float,int,long,andshort(*)
boolean,byte,string,thread,int,double,longandshort
object,byte,string,char,float,int,longandshort
boolean,thread,stringbuffer,char,int,float,longandshort
boolean, thread,char,double,float,int,longandshort
Correct
10. Selectthe declarationandinitializationstatementthatwill holdthe letterJ. Mark for Review
(1) Points
int letter='J';
5. floatletter='J';
Stringletter='J';
char letter='J';(*)
Correct
Previous Page 2 of 10 Next Summary
Test:Java FundamentalsFinal Exam
Reviewyouranswers,feedback,andquestionscoresbelow.Anasterisk(*) indicatesacorrect
answer.
Section4
(Answerall questionsinthissection)
11. Whichof the followingare relationaloperatorsinJava? Mark for Review (1) Points
(Choose all correctanswers)
< (*)
<= (*)
=
!= (*)
All of the above.
Correct
12. What isthe outputof the followinglinesof code?
intj=6,k=4,m=12,result;
result=j/m*k;
System.out.println(result); Mark for Review (1) Points
2
0 (*)
48
24
Correct
6. 13. Whichof the followingisthe name of a Java primitive datatype? Mark forReview
(1) Points
Object
Rectangle
double (*)
String
Correct
14. The three logicoperatorsinJava are: Mark forReview (1) Points
&&, ||, ! (*)
!=,=,==
&&,!=,=
&,|,=
Correct
15. The six relational operatorsinJavaare: Mark for Review (1) Points
>,<,=,!,<=,>=
>,<,==,!=,<=,>= (*)
>,<,=,!=,<=,>=
>,<,=,!=,=<,=>
Correct
Previous Page 3 of 10 Next Summary
Test:Java FundamentalsFinal Exam
Reviewyouranswers,feedback,andquestionscoresbelow.Anasterisk(*) indicatesacorrect
answer.
Section5
16. All of the followingare essential toinitializingaFORloop,exceptwhichone? Mark for Review
(1) Points
Initializingthe iterator(i).
Havinga conditional statement.
7. Updatingthe counter.
Havingan if statement.(*)
Correct
17. Updatingthe inputof a loopallowsyoutoimplementthe code withthe nextelementrather
than repeatingthe code alwayswiththe same element.True orfalse? Mark for Review (1) Points
True (*)
False
Correct
18. What isthe outputof the followingcode segment?
intnum = 7;
while(num>=0)
{
num-= 3;
}
System.out.println(num); Mark for Review (1) Points
-2 (*)
1
0
2
Correct
19. Why are loopsuseful? Mark forReview (1) Points
Theysave programmersfromhavingto rewrite code.
Theyallowforrepeatingcode a variable numberof times.
Theyallowforrepeatingcode until acertainargumentismet.
All of the above.(*)
Incorrect.RefertoSection5 Lesson1.
20. Whichof the followingcallsthe methodcalculate correctly?
8. Mark for Review(1) Points
ThisClasst=newThisClass();intx=t.calculate(3,4);(*)
int x=calculate(3,4);
ThisClasst=newThisClass();intx=t.calculate(3);
ThisClasst=newThisClass();intx=t.calculate();
Incorrect.RefertoSection5 Lesson2.
Previous Page 4 of 10 Next Summary
Test:Java FundamentalsFinal Exam
Reviewyouranswers,feedback,andquestionscoresbelow.Anasterisk(*) indicatesacorrect
answer.
Section5
21. A classcan onlyhave one constructor.True or false? Mark for Review (1) Points
True
False (*)
Correct
22. What value will returnforj whenthe setValue methodiscalled?
9. Mark for Review(1) Points
31
32
10
11 (*)
Correct
23. The followingstatementcompilesandexecutes.Whatdoyouknow for certain?
tree.grows(numFeet); Mark for Review(1) Points
numFeetmustbe an int.
tree must be the name of the class.
grows mustbe the name of an instance field.
grows mustbe the name of a method.(*)
tree must be a method.
Correct
24. The followingcode createsanObjectof type Animal.True orfalse?
Animal a=newAnimal(); Mark for Review (1) Points
True (*)
False
Correct
10. 25. The followingcode createsanObjectof type Horse.True or false?
Whale a=newWhale(); Mark for Review (1) Points
True
False (*)
Correct
Previous Page 5 of 10 Next Summary
Test:Java FundamentalsFinal Exam
Reviewyouranswers,feedback,and questionscoresbelow.Anasterisk(*) indicatesacorrect
answer.
Section5
26. The followingcode isagoodexample of usingthe thisreference.True orfalse?
Mark for Review(1) Points
True
False (*)
Correct
Section6
27. The followingarraydeclarationisvalid.True orfalse?
int[] y= newint[5]; Mark forReview(1) Points
True (*)
False
Correct
28. What isthe outputof the followingsegmentof code? Mark forReview (1) Points
11. 456789
777777 (*)
555555
987654
Thiscode doesn'tcompile.
Correct
29. Whichof the followingstatementsisnota validarraydeclaration? Mark for Review
(1) Points
int number[];
float[]averages;
double marks[5];
counterint[];(*)
Incorrect.RefertoSection6 Lesson1.
30. What isthe outputof the followingsegmentof code?
intarray[][] = {{1,2,3},{3,2,1}};
for(inti=0;i<2;i++)
for(intj=0;j<3;j++)
System.out.print(2*array[1][1]); Mark forReview (1) Points
444444 (*)
123321
246642
222222
This code doesn'tcompile.
Correct
Previous Page 6 of 10 Next Summary
12. Test:Java FundamentalsFinal Exam
Reviewyouranswers,feedback,andquestionscoresbelow.Anasterisk(*) indicatesacorrect
answer.
Section6
31. Considerthe followingcode snippet
Stringforest= newString("Black");
System.out.println(forest.length());
What isprinted? Mark for Review(1) Points
5 (*)
6
7
Black
Forest
Correct
32. Whichof the followingcreatesaStringnamedChar? Mark for Review (1) Points
char string;
StringChar; (*)
char Char;
char char;
Stringchar;
Correct
33. The followingcode isanexample of acorrectinitializationstatement:
char c="c"; Mark for Review(1) Points
True
False (*)
Correct
34. The == operatorcan be usedto compare twoStringobjects.The resultisalwaystrue if the two
stringsare have the exactsame characters ineach positionof the String.True or false? Mark for
Review(1) Points
13. True
False (*)
Correct
35. Whichof the followingcouldbe areasonto throw an exception? Mark for Review
(1) Points
To eliminate exceptionsfromdisruptingyourprogram.(*)
You have a fatal errorin yourprogram.
You have encounteredaStackOverflow Error.
To make the userinterface hardertonavigate.
Correct
Previous Page 7 of 10 Next Summary
Test:Java FundamentalsFinal Exam
Reviewyouranswers,feedback,andquestionscoresbelow.Anasterisk(*) indicatesacorrect
answer.
Section6
36. Whichof the followingcorrectlymatchesthe symbol withitsfunction? Mark for Review
(1) Points
(Choose all correctanswers)
== (twoequal signs) comparesvaluesof primitivetypessuchasintor char. (*)
14. == (twoequal signs) comparesthe valuesof non-primitiveobjects.
== (twoequal signs) comparesthe memorylocationof non-primitiveobjects.(*)
= (single equalssign) comparesthe value of primitive typessuchasint or char.
.equals()comparesthe value of non-primitive objects.(*)
Correct
37. If an exceptionisthrownbya method,where canthe catch for the exceptionbe? Mark for
Review
(1) Points
There doesnot needtobe a catch inthissituation.
The catch must be inthe methodthat threw the exception.
The catch can be inthe methodthat threw the exceptionorinanyothermethodthatcalledthe
methodthatthrewthe exception.(*)
The catch must be immediatelyafterthe throw.
Incorrect.RefertoSection6 Lesson3.
15. 38. Suppose youare writinga programwhere the userispromptedtothe give coordinateswhere
theybelievethe princessisinside of the castle.
Your program movesthe prince tothe coordinatesthatthe user specified.If the princessisnot
foundat those coordinates,the userisgivenaclue thathelpsthemguesscoordinatesclosertothe
princess.The userisallowedto entertheirnew guessof where the princessis.
Assume yourprogramdoesnot take intoconsiderationthe possibilitythatthe usermayenter
coordinatesoutside of the castle where the princesscouldnotbe.Whatwouldbe the resultof the
userenteringcoordinatesoutside of the castle?How couldthisbe handledinyourcode? Mark for
Review
(1) Points
(Choose all correctanswers)
Anerror wouldoccur.Errors cannot be handledbycode.
Anexceptionwouldoccurbutcouldnot be handledinside yourcode.The userwouldhave to
restartthe programand enterpropercoordinates.
Anexceptionwouldoccur.Thiscouldbe handledbythrowingthe exceptioninyourcode if the
userentersinvalidcoordinates.Whenthe exceptioniscaught,the prince couldbe movedtothe
coordinate inside the castle thatisclosesttothose thatthe userspecified.(*)
Anexceptionwouldoccur.Thiscouldbe handledbythrowinganexceptioninyourcode if the
userentersinvalidcoordinates.Whenthe exceptioniscaught,the usercouldbe promptedtoenter
coordinateswithinthe givenrange of the castle.(*)
Incorrect.RefertoSection6 Lesson3.
16. Section7
(Answerall questionsinthissection)
39. Anaccess modifierisakeywordthatallowssubclassestoaccessmethods,data,and
constructorsfrom theirparentclass.True or false? Mark forReview (1) Points
True (*)
False
Incorrect.Referto Section7 Lesson3.
40. Whichof the followingisthe correctway tocall an overridenmethodneedOil() of asuperclass
Robotin a subclassSqueakyRobot? Mark for Review (1) Points
Robot.needOil(SqueakyRobot);
SqueakyRobot.needOil();
super.needOil();(*)
needOil(Robot);
Incorrect.RefertoSection7 Lesson3.
Previous Page 8 of 10 Next Summary
Test:Java FundamentalsFinal Exam
Reviewyouranswers,feedback,andquestionscoresbelow.Anasterisk(*) indicatesacorrect
answer.
Section7 (Answerall questionsinthissection)
41. What isthe JavaApplet? Mark for Review (1) Points
(Choose all correctanswers)
It isthe virtual machine thattranslatesJavacode intoa representationthatthe computercan
understand.
A web-basedJavaprogramthatis embeddedintoawebbrowser.(*)
A graphic visual includedinJava.(*)
There isno suchthingas a JavaApplet.
Incorrect.RefertoSection7 Lesson3.
17. 42. Whichsegmentof code representsacorrectway to define avariable argumentmethod?
Mark forReview(1) Points
StringeasyArray(String...elems){//code} (*)
StringeasyArray(...Stringelems){//code}
String...easyArray(Stringelems){//code}
IntegereasyArray...(intelems) {//code}
Correct
43. Whichof the followingisthe correctway tocode a methodwitha returntype an object
Automobile? Markfor Review(1) Points
Automobileupgrade(StringcarA){
carA="Turbo";
returncarA;}
Automobile upgrade(Automobile carA){
carA.setTurbo("yes");
returncarA;} (*)
Stringupgrade(StringcarA){
carA="Turbo";
returncarA;}
upgrade(Automobile carA) Automobile{
carA.setTurbo("yes");
returncarA;}
None of the above.Itisnot possible toreturnanobject.
Correct
18. 44. Choose the correctimplementationof apublicaccessmodifierforthe methoddivide. Mark
for Review(1) Points
divide(inta,intb,public) {returna/b;}
publicdivide(inta,intb) {returna/b;}(*)
divide(inta,intb) {publicreturna/b;}
divide(publicinta,publicintb) {returna/b;}
Correct
45. Staticmethodscan readinstance variables.True orfalse? Mark for Review (1) Points
True
False (*)
Correct
Previous Page 9 of 10 Next Summary
Test:Java FundamentalsFinal Exam
Reviewyouranswers,feedback,andquestion scoresbelow.Anasterisk(*) indicatesacorrect
answer.
Section7 (Answerall questionsinthissection)
46. Staticmethodscan write toclass variables.True orfalse? Mark for Review (1) Points
True (*)
False
Incorrect.RefertoSection7 Lesson2.
47. A staticvariable isalwayspubliclyavailable.True orfalse? Mark for Review (1) Points
True
False (*)
Correct
48. Abstractclassescannotimplementinterfaces.True orfalse? Mark for Review (1) Points
True
False (*)
Incorrect.RefertoSection7 Lesson4.
19. 49. If Oak extendsTree,itispossibletodeclare anobjectsuchthat
Tree grandfatherT= newOak();
True or false? Mark for Review(1) Points
True (*)
False
Correct
50. Abstractclass cannotextendanotherabstractclass.True or false? Mark for Review
(1) Points
True
False (*)
Correct
Previous Page 10 of 10 Summary