CSE 132 (Spring 2015)
Quiz 1: Practice Problems

Model View Controller
  1. For each scenario below, discuss the appropriateness of the scenario in terms of the Model View Controller pattern:
    • A program sends messages to a JSlider to change the value of a model variable.
    • A user interacts wtih a JSlider to change the value of a model variable.
    • When the text of a model is updated, the view of that text does not show the changes that were made.
  2. Recall the Vector class from CSE131 for representing two-dimensional vectors.

    How would you represent and manipulate Vectors using the model view controller pattern:

    • How would you represent the model?
    • What are potential interaction modes with a user and a Vector?
    • What are some potential display modes (views) for a Vector?

Exceptions
  1. How do exceptions and try...catch work?
  2. What is the difference between a checked and an unchecked exception?
  3. What options do you have in terms of writing software that deals with checked exceptions?

Persistence and I/O
  1. How is an int represented persistently using writeInt(int)?
  2. How is a boolean represented persistently using writeBoolean(boolean)?
  3. When you read a text file byte-by-byte, and receive each text character as a byte, what do you see?
  4. After writing the value 132, why did it read as -124?
  5. What is the 2's complement representation in 4 bits of
    • 5
    • -5
  6. Using 2's complement arithmetic in 4 bits, show how the problem
      5 - 5
    
    is computed using addition instead of subtraction.
  7. What happens if you try to take the 2's complement of 0 (0000) using 4 bits?
  8. What happens if you try to take the 2's complement of -8 (1000) using 4 bits? Why is that result OK?


Last modified 12:47:29 CST 01 February 2015 by Ron K. Cytron