Search Header Logo

AP CSA Unit 3 Review

Authored by Mark Freeman

Computers

12th Grade

Used 1+ times

AP CSA Unit 3 Review
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

17 questions

Show all answers

1.

OPEN ENDED QUESTION

3 mins • 1 pt

Media Image

Consider the following code which uses the int variable boxes: if (boxes <= 0) { System.out.println("empty"); } else if (boxes < 12) { System.out.println("still need more"); } else { System.out.println("good enough"); } Which of the following will always produce the same result as the code above, regardless of the value of boxes?

Evaluate responses using AI:

OFF

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

Consider the following incomplete code segment. Consider the following potential replacements for /* missing code */. Which of these replacements will cause the code segment to always print no?

(int) (Math.random()) * 15 → Math.random can produce a 0 so this would be correct

(int) (Math.random() * 10) + 5 → Math.random cannot produce a one so this would be the only false answer

(int) (Math.random() * 10) + 10 → Math.random * 10 can produce a 5

(int) (Math.random() * 15) + 15 → Math.random can produce a zero

(int) (Math.random() + 15) → This could be rounded off to a 15

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

Given the variables, which boolean condition is true?

a < b && a == b → this can not be logically true

a < b && a != b → this can not be logically true

b >= a || a >= b → This is like the commutative property and a and b are the same value so this is true

a > b || a != b → Both premises are false in this case

None → Answer c is the correct answer

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

The following if statement determines the amount of customers that come in at the Java Restaurant. It uses the double variable low, amount, and high. Which replacement code is equivalent to the original if statement?

if (amount > low) { if (amount < high) { System.out.println("Amount of customers could be better."); } else { System.out.println("Amount of customers is great!"); } } else { System.out.println("Amount of customers is great!"); }

if (amount > low) { if (amount < high) { System.out.println("Amount of customers could be better."); } } else { System.out.println("Amount of customers is great!"); }

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

The following truth table matches which boolean condition?

A && (A && B) → doesn’t apply to line 1

A || (!A && !B) → only applies to line 1

!A && (A || B) → equivalent to !A && B which the table reflects

A || (A || B) → only applies to line 4

!A && (A || !B) → does not apply to line 4

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

An app records the amount of boxes a warehouse has using the int amount. The app also uses a String variable diagnosis in order to determine if the warehouse requires more boxes. The values of both amount and diagnosis are shown below. Which of the following code segments will correctly set the value of diagnosis for any given value of amount?

if (amount >= 75) { diagnosis = "More than enough"; } if (amount <= 74) { diagnosis = "Enough"; } if (amount <= 50) { diagnosis = "Need more"; } else { diagnosis = "Need way more"; }

if (amount >= 75) { diagnosis = "More than enough"; } else if (amount >= 50) { diagnosis = "Enough"; } else if (amount >= 25) { diagnosis = "Need More"; } else { diagnosis = "Need way more"; }

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

To test if a grade (represented by the variable g) is a D (between 69 and 59, including 69 but excluding 59) you would use the following if statement: if ( g ______ 69 ______ g ______ 59 ) What set of three symbols correctly fills the blanks in the order they appear?

>=, &&, <= → g cannot be higher than 69

<, &&, > → g can be equal to 69

<=, &&, > → this is correct because g must be lower than or equal to 69 and it must be higher than 59

<, ||, > → It is not a either or case

<=, &&, >= → g cannot be equal to 59

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?