AP CS A Unit 3 Review
Flashcard
•
Computers
•
11th - 12th Grade
•
Practice Problem
•
Hard
ZenonTS ZenonTS
FREE Resource
Student preview

17 questions
Show all answers
1.
FLASHCARD QUESTION
Front
What is output by the following code? Options: 11, 15, 31, error
Back
11
Answer explanation
The x * 3 is equal to 30 so the first if runs and increments x (which is 10) by one. Then
since 11 is smaller than 31, it will not run the second if, thus printing 11
2.
FLASHCARD QUESTION
Front
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 false ? Assume that Math is imported correctly into our program.Options: (int)(Math.random() * 10) + 20, (int)(Math.random() * 10) + 25, (int)(Math.random() * 10) + 30, (int)(Math.random() + 30)
Back
(int)(Math.random() * 10) + 20
Answer explanation
Math.random() returns a random value between 0 (inclusive)
and 1 (exclusive). So Math.random()*10 + 20 can give values
between 20.0 and 29.9999... By typecasting the value to an int,
the decimal values are truncated, which gives a range from 20 to
29 inclusive, meaning it never returns 30, and false is always
printed as a result
3.
FLASHCARD QUESTION
Front
Given the variables, which boolean condition is true?
Options: a < b && a == b, a > b || a != b, a < b && a != b, b >= a && a >= b
Back
b >= a && a >= b
Answer explanation
This is equivalent to a == b, which is true
4.
FLASHCARD QUESTION
Front
The following truth table matches which boolean condition? A && ( A || B ), A && ( A && B ), !A && ( A || !B ), A || ( A || B )
Back
A || ( A || B )
Answer explanation
This is equivalent to A || B which the truth table reflects
5.
FLASHCARD QUESTION
Front
To test if a grade (represented by the double variable g) is a B (between 80 - inclusive - and 90 exclusive), what set of three symbols correctly fills in the blanks in the order they appear? Options: >=, &&, <; >=, ||, <; >, ||, <=; <=, &&, >
Back
>=, &&, <
Answer explanation
We want inclusive of the lower bound and exclusive of the upper bound, so we
need to use >= and <, and we need both conditions to be true so we use &&
6.
FLASHCARD QUESTION
Front
Result of evaluating the expression with boolean variables x and y.
Back
True only when x and y have different values.
Answer explanation
(x||y) - x or y must be true; && - and the next expression must be true; !(x&&y) - x and y can not both be true
7.
FLASHCARD QUESTION
Front
Consider the following code fragment, assume val is an int: Which of the following code fragments would have the same effect? Options: if (!(val == 50 || val < 0)), if (val == 50 || val > 0), if (val == 50 || val < 0), if (val == 50 && val < 0)
Back
if (val == 50 || val < 0)
Answer explanation
When val is a negative value or 50, it should evaluate to true, this is the
proper use of De Morgan’s law (&& will change to ||)
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
8 questions
EL CONSUMISMO
Flashcard
•
12th Grade
18 questions
8A REGLEMENTATION UDPS-83 EXAMEN BLANC FLASH
Flashcard
•
KG
12 questions
Like to vs Would like to - course 6 (2H)
Flashcard
•
9th - 12th Grade
11 questions
Analizing Essay Titles
Flashcard
•
University
13 questions
7517 03 Basic Operations in Programming Languages
Flashcard
•
9th Grade - University
14 questions
CADEIA ALIMENTAR
Flashcard
•
KG
10 questions
I Wandered Lonely As A Cloud By William Wordsworth
Flashcard
•
12th Grade
15 questions
História do Brasil e Portugal
Flashcard
•
12th Grade
Popular Resources on Wayground
5 questions
This is not a...winter edition (Drawing game)
Quiz
•
1st - 5th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
10 questions
Identify Iconic Christmas Movie Scenes
Interactive video
•
6th - 10th Grade
20 questions
Christmas Trivia
Quiz
•
6th - 8th Grade
18 questions
Kids Christmas Trivia
Quiz
•
KG - 5th Grade
11 questions
How well do you know your Christmas Characters?
Lesson
•
3rd Grade
14 questions
Christmas Trivia
Quiz
•
5th Grade
20 questions
How the Grinch Stole Christmas
Quiz
•
5th Grade
Discover more resources for Computers
26 questions
Christmas Movie Trivia
Lesson
•
8th Grade - Professio...
15 questions
Christmas Song Emoji Pictionary
Quiz
•
7th - 12th Grade
20 questions
Christmas Movies
Quiz
•
1st - 12th Grade
55 questions
CHS Holiday Trivia
Quiz
•
12th Grade
20 questions
Christmas Movie Trivia
Quiz
•
9th - 12th Grade
29 questions
christmas facts
Lesson
•
5th - 12th Grade
20 questions
Christmas Trivia
Quiz
•
5th - 12th Grade
20 questions
Stages of Meiosis
Quiz
•
9th - 12th Grade