100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Java Programming EXAM 2 100% ACCURATE!! CA$21.77   Add to cart

Exam (elaborations)

Java Programming EXAM 2 100% ACCURATE!!

 12 views  0 purchase
  • Course
  • Java
  • Institution
  • Java

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 ...

[Show more]

Preview 2 out of 13  pages

  • August 2, 2024
  • 13
  • 2024/2025
  • Exam (elaborations)
  • Questions & answers
  • Java
  • Java
avatar-seller
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

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller papersmaster01. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for CA$21.77. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

76747 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
CA$21.77
  • (0)
  Add to cart