A1

  1. How many bits does it take to represent the values from 0 to 255?
  • 8 bits
  1. How many bytes does it take to represent a color in the RBG color model?
  • 3 bytes
  1. How many pixels are in a picture that is 640 pixels wide and 480 pixels high?
  • 307,200 pixels (640 * 480)

A2

  1. Pink: r=255 g=192 b=202
  2. Yellow: r=255 g=255 b=0
  3. Purple: r=128 g=0 b=125
  4. White: r=255 g=255 b=255
  5. Dark Gray: r=169 g=169 b=169

A3

  1. Top left row index? 0.
  2. Top left column index? 0.
  3. Right most column index (width 640)? 639.
  4. Bottom most row index (height 480)? 479.
  5. Row index increase direction? Top to bottom.
  6. Column index increase direction? Left to right.
  7. Zoom 500%, see squares (pixelation)? Yes.

A5

  1. getPixels2D in Picture.java? No (it’s inherited).
  2. getPixels2D in SimplePicture.java? Yes.
  3. DigitalPicture p = new DigitalPicture(); compiles? No (interface).
  4. DigitalPicture p = new SimplePicture(); compiles? Yes (polymorphism).
  5. DigitalPicture p = new Picture(); compiles? Yes (polymorphism).
  6. SimplePicture p = new Picture(); compiles? Yes (polymorphism).
  7. Picture p = new SimplePicture(); compiles? No (cannot assign superclass to subclass variable directly).
  8. (Implicit) What good is an interface method without a body? Defines a contract for implementing classes.

A7

  1. Body executions (row 7-16, col 6-14)? 90 times.
  2. Body executions (row 5-11, col 3-18)? 112 times.