AP CSP Unit 2: Binary and Data Representation

290 multiple-choice questions on AP Computer Science Principles Unit 2, Binary and Data Representation, organized by topic. They are not tied to any one class or teacher: they follow the College Board course framework. Learn the 30 key terms with the flashcards first, then test yourself. Every answer comes with a short explanation.

Take the practice test · Flashcards · All study tools

What it covers

  1. 2.1 Bits and binary numbers
  2. 2.2 Limits of representation
  3. 2.3 Analog and digital data

Key terms

2.1 Bits and binary numbers

Nibble
A group of 4 bits, equal to one hexadecimal digit
Hexadecimal
The base-16 number system using digits 0–9 and A–F
ASCII
A character encoding that maps common English letters, digits, and symbols to numbers stored in binary
Unicode
A character encoding that can represent letters and symbols from many writing systems
Most significant bit
The leftmost bit in an unsigned binary integer, which has the largest place value
Least significant bit
The rightmost bit in a binary integer, which has place value 1
Bit pattern
A specific sequence of 0s and 1s whose meaning depends on how a program interprets it
Character encoding
An agreed-upon mapping from characters to numbers that are then stored as bits

2.2 Limits of representation

Unsigned integer
A whole-number representation that uses all of its bits for magnitude and cannot store negatives
Signed integer
A whole-number representation that reserves a way to store negative values, shrinking the positive maximum
Sign bit
In a signed integer representation, the bit that distinguishes negative values from nonnegative ones
Floating-point representation
A way of storing real numbers with a fixed number of bits for a fraction and a magnitude
Finite precision
The limit that only a finite set of values can be stored exactly when a fixed number of bits is used
Representable range
The interval of values that a fixed-size representation can store
Binary fraction
A fractional value written with place values of 1/2, 1/4, 1/8, and so on

2.3 Analog and digital data

Bit
A binary digit, 0 or 1
Byte
8 bits
Binary
The base-2 number system using digits 0 and 1
Fixed-size integers
Integers stored with a set number of bits, limiting their range
Round-off error
Imprecision from approximating real numbers with limited bits
Analog data
Data with continuously changing values
Sampling
Measuring an analog signal at discrete intervals
Abstraction
Reducing complexity by hiding details
Digital data
Data stored as a finite set of discrete values, typically sequences of bits
Pixel
One cell in the grid that makes up a digital image, with a stored color or brightness value
RGB
A common pixel encoding that stores separate intensities for red, green, and blue
Color depth
The number of bits used to store the color or brightness of one pixel
Bit depth
The number of bits used to store one sample, such as an audio amplitude or a pixel value
Sampling rate
The number of samples taken from an analog signal each second, or per unit of time
Analog-to-digital conversion
The process of sampling an analog signal, mapping each sample to a finite level, and storing those levels as bits

Sample practice questions

  1. A bit is

    1. a group of 8 binary digits
    2. a single decimal digit, 0–9
    3. a binary digit, either 0 or 1
    4. a unit of processing time

    Answer: C. a binary digit, either 0 or 1 Bit is short for binary digit. A byte is 8 bits.

  2. Some programming languages represent integers using a fixed number of bits. This can cause

    1. overflow errors when results are too large to represent
    2. syntax errors when large numbers are typed into the code
    3. programs to run faster when working with large numbers
    4. automatic compression of data that uses large numbers

    Answer: A. overflow errors when results are too large to represent Fixed-size integers have a maximum value.

  3. Analog data

    1. have values that change smoothly rather than in discrete steps
    2. are always stored as sequences of 0s and 1s in a computer
    3. can't be measured, only estimated by human observers
    4. are only text, such as handwritten letters and notes

    Answer: A. have values that change smoothly rather than in discrete steps Examples include sound waves, temperature and the position of a needle on a gauge.

  4. How many bits are in a byte?

    1. 4
    2. 16
    3. 2
    4. 8

    Answer: D. 8 One byte = 8 bits.

  5. Real numbers stored in a computer can produce round-off errors because

    1. computers can't store decimal numbers at all, only whole numbers
    2. some numbers can't be represented exactly with a fixed number of bits
    3. binary numbers are always negative, so they must be rounded up
    4. round-off only happens on old computers with slow processors

    Answer: B. some numbers can't be represented exactly with a fixed number of bits For example, 0.1 has no exact finite binary representation, so it is approximated.

  6. Sampling is a technique used to

    1. compress text files by removing repeated characters and spaces
    2. approximate analog data digitally by measuring values at intervals
    3. encrypt messages so that only the intended recipient can read them
    4. send data over the internet in small packets along different routes

    Answer: B. approximate analog data digitally by measuring values at intervals Digital audio samples a sound wave many times per second.

  7. What is the decimal value of the binary number 1011?

    1. 13
    2. 9
    3. 11
    4. 1011

    Answer: C. 11 8 + 0 + 2 + 1 = 11.

  8. In many programming languages, the expression 0.1 + 0.2 == 0.3 evaluates to false because of

    1. round-off error in floating-point representation
    2. integer overflow in the addition of two numbers
    3. a syntax error in the way the decimals are written
    4. a logic error in the programmer's arithmetic

    Answer: A. round-off error in floating-point representation The stored values are approximations, so the sum differs slightly from 0.3.

  9. Increasing the sampling rate when digitizing sound

    1. reduces the file size, since each sample stores less information
    2. makes the digital copy closer to the original, but requires more data
    3. has no effect on quality, since sound is already stored in binary
    4. removes all background noise from the original analog recording

    Answer: B. makes the digital copy closer to the original, but requires more data More samples capture more detail at the cost of storage.

  10. What is 25 in binary?

    1. 11001
    2. 10011
    3. 11010
    4. 10101

    Answer: A. 11001 25 = 16 + 8 + 1, so 11001.

Practice all 290 questions

More AP Computer Science Principles

Studying for a test in your own class? Make a practice test from your class notes.