100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

Java Programming EXAM 2 100% ACCURATE!!

Rating
-
Sold
-
Pages
13
Grade
A+
Uploaded on
02-08-2024
Written in
2024/2025

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

Show more Read less
Institution
Java
Course
Java









Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
Java
Course
Java

Document information

Uploaded on
August 2, 2024
Number of pages
13
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

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

Get to know the seller

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 Howard Community College
View profile
Follow You need to be logged in order to follow users or courses
Sold
278
Member since
2 year
Number of followers
106
Documents
14064
Last sold
3 days ago
PAPERSMASTER01

On this page you will find documents , package deals, flashcards offered by seller PAPERSMASTER01.With our documents on your side you"ll be well equipped to tackle you exams and achieve the grades you need.

3.9

71 reviews

5
22
4
33
3
9
2
3
1
4

Recently viewed by you

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

Frequently asked questions