• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 2 out of 13 pages
Exam (elaborations)

Java Programming EXAM 2 100% ACCURATE!!

Document preview thumbnail
Preview 2 out of 13 pages

CH 6 - ANSWER A structure that allows repeated execution of a block of statements is a ___________. - ANSWERloop A loop that never ends is a(n) ___________ loop - ANSWERinfinite To construct a loop that works correctly, you should initialize a loop control ___________. - ANSWERvariable What is the output of the following code? b = 1; while(b 4) S(b + " "); - ANSWER1 1 1 1 1 1... Why? - ANSWERWhen b is 1, the comparison in the while statement is true, so 1 prints. The comparison is made again, it is still true (because b is still 1), and 1 prints again. The value 1 prints infinitely because b is never altered. What is the output of the following code? b = 1; while(b 4) { S(b + " "); b = b + 1; } - ANSWER1 2 3

Content preview

Java Programming EXAM 2 100% ACCURATE!!

CH 6 - ANSWER



A structure that allows repeated execution of a block of statements is a ___________. - ANSWERloop



A loop that never ends is a(n) ___________ loop - ANSWERinfinite



To construct a loop that works correctly, you should initialize a loop control ___________. -
ANSWERvariable



What is the output of the following code?

b = 1;

while(b < 4)

System.out.print(b + " "); - ANSWER1 1 1 1 1 1...



Why? - ANSWERWhen b is 1, the comparison in the while statement is true, so 1 prints. The
comparison is made

again, it is still true (because b is still 1), and 1 prints again. The value 1 prints infinitely

because b is never altered.



What is the output of the following code?

b = 1;

while(b < 4)

{

System.out.print(b + " ");

b = b + 1;

} - ANSWER1 2 3



Why?? - ANSWERWhen b is 1, the comparison in the while statement is true, so 1 is output. Then b
becomes 2,

, the Boolean evaluation is still true, and 2 is output. The b becomes 3, the Boolean evaluation is

true and 3 is output. Then b becomes 4, the Boolean expression is false, and the loop ends.



What is the output of the following code?

e = 1;

while(e < 4);

System.out.print(e + " "); - ANSWERnothing



WHYY - ANSWERThe semicolon at the end of the second line creates an empty loop body. The value
of e remains

1 forever; it keeps being compared to 4 infinitely



If total = 100 and amt = 200, then after the statement total += amt, ___________. - ANSWERtotal is
equal to 300



whyyyy - ANSWERThe statement total += amt is equivalent to total = total + amt



The prefix ++ is a ___________ operator. - ANSWERa. unary



If g = 5, then after h = ++g, the value of h is ___________. - ANSWER6



If m = 9, then after n = m++, the value of m is ___________. - ANSWER10



why? - ANSWERThe variable n receives the value of m prior to incrementing



If j = 5 and k = 6, then the value of j++ == k is ___________. - ANSWERfalse



whyyyyyyyyyy - ANSWERThe value of j++ is 5, so it does not equal k. After this statement executes, j
will be 6, but that

will be after the value of this comparison has been determined.



You must always include ___________ in a for loop's parentheses - ANSWER2 semicolons

Document information

Uploaded on
August 2, 2024
Number of pages
13
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$15.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.
papersmaster01
3.9
(74)
Sold
309
Followers
106
Items
14763
Last sold
1 month ago




Why students choose Stuvia

Created by fellow students, verified by reviews

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

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card 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