Question 1
Consider this code segment: int x = 10, y = 0; while (x > 5) { y = 3; while (y < x) { y *= 2; if (y % x == 1) y += x; } x -= 3; } System.out.println(x + " " + y); What will be output after execution of this code segment?
Correct Answer:
7 12
Explanation:
Correct answer: 7 12
Question 2
In Java, a variable of type int is represented internally as a 32-bit signed integer. Suppose that one bit stores the sign, and the other 31 bits store the magnitude of the number in base 2. In this scheme, what is the largest value that can be stored as type int ?
Correct Answer:
231 − 1
Explanation:
Correct answer: 231 − 1
Question 3
A common use of hexadecimal numerals is to specify colors on web pages. Every color has a red, green, and blue component. In decimal notation, these are denoted with an ordered triple (x, y, z), where x, y, and z are the three components, each an int from 0 to 255. For example, a certain shade of red, whose red, green, and blue components are 238, 9, and 63, is represented as (238, 9, 63). In hexadecimal, a color is represented in the format #RRGGBB, where RR, GG, and BB are hex values for the red, green, and blue. Using this notation, the color (14, 20, 255) would be coded as #RRGGBB. Which of the following hex codes represents the color (14, 20, 255)?
Correct Answer:
#0E14FF
Explanation:
Correct answer: #0E14FF
Question 4
Suppose that base-2 (binary) numbers and base-16 (hexadecimal) numbers can be denoted with subscripts, as shown below: 2Ahex = 101010bin Which is equal to 3Dhex ?
Correct Answer:
111101bin
Explanation:
Correct answer: 111101bin
Question 5
The following fragment intends that a user will enter a list of positive integers at the keyboard and terminate the list with a sentinel: int value = 0; final int SENTINEL = -999; while (value != SENTINEL) { //code to process value ... value = IO.readInt(); //read user input } The fragment is not correct. Which is a true statement?
Correct Answer:
The code will always process a value that is not on the list.
Explanation:
Correct answer: The code will always process a value that is not on the list.
Question 1
Exam overview

About this Exam

Prepare with the AP Computer Science Unit 1 - Test Review Practice Questions practice quiz. This question bank includes 20 questions covering value, count, code, segment, and expression. Use it to review important concepts, identify knowledge gaps, and build confidence for the related exam, course, or assessment.

More details

Additional Information

AP Computer Science Unit 1 - Test Review Practice Questions

This practice set contains 20 questions from the matching question bank and focuses on value, count, code, segment, and expression. Work through each question carefully, review the provided solutions, and revisit topics that need more study before your next attempt.

This is an independent study resource intended for practice and review; it is not an official examination or an endorsement by any organization named in the title.

Quiz information

Frequently Asked Questions

The complete question count is available after full access is unlocked.
No fixed duration is currently configured for this quiz.
Question explanations are included where they are available in the quiz content, helping you review the reasoning after answering.
Yes. You can retake the practice test again as you continue studying during your available access period.
After your access is confirmed, you can continue into the complete practice exam from this quiz flow.
Unless explicitly stated otherwise, this page provides independent practice material for study and exam preparation and is not the official examination itself.
Keep studying

Related Questions