100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
AP Computer Science A Unit 4 Study Guide $11.49   Add to cart

Exam (elaborations)

AP Computer Science A Unit 4 Study Guide

 8 views  0 purchase
  • Course
  • AP COMPUTER SCIENCE
  • Institution
  • AP COMPUTER SCIENCE

AP Computer Science A Unit 4 Study Guide

Preview 2 out of 7  pages

  • July 30, 2024
  • 7
  • 2023/2024
  • Exam (elaborations)
  • Questions & answers
  • AP COMPUTER SCIENCE
  • AP COMPUTER SCIENCE
avatar-seller
millyphilip
AP Computer Science A Unit 4 Study Guide
int a = 0;
int b = 0;
while (a < 5 && b < 3) {
System.out.println(a + " " + b);a++;b++;
}
What is output? - Answer -0 0 1 1 2 2
int n = 14;
while (!(n % 3 == 0 && n % 5 == 0)) {
System.out.println(n);
n += 2;
}
What is the last number printed by this code? - Answer -28
What is one potential problem with the following loop?
System.out.print("Enter integers. Enter -1 to exit.");
System.out.println(" Count of integers entered will be returned.");
int n = 0;
int c = 0
;while (n != -1) {
n = scan.nextInt();
c++;
}
System.out.println(c); - Answer -The loop counts when the user enters -1 into the keyboard, so the count will be one too many.
What is one potential problem with the following loop?
int n = 5;
while (n != -1) {
System.out.println(n);
} - Answer -Since n does not change the loop will not stop.
int n = 4;
while (n <= 15) {
n += 2;
System.out.print(n + " ");
}
What is output? - Answer -6 8 10 12 14 16
int n = 80;
while (n > 40) {
System.out.print(n % 10 + " ");
n -= 5;
}
What is output? - Answer -0 5 0 5 0 5 0 5
What is output to the screen by the following code:
int n = 3;
while (n < 7)
{
n++;
System.out.print(n + " ");
} - Answer -4 5 6 7
What is output to the screen by the following code:
int n = 10;
while (5 < n)
{
n--;
System.out.print(n + " ");
} - Answer -9 8 6 7 5
Often on the AP exam they ask you to print out the first and last number printed by a loop. What are the first and last values printed by:
int n = 5;
while (n < 32) {
n += 5;
System.out.print(n + " ");
} - Answer -10 35
What are the first and last numbers printed by the following code:

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 millyphilip. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

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

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

67096 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
$11.49
  • (0)
  Add to cart