In-Class Quiz 4 Topics

The quiz will cover all of Chapter 8 (testing) and all of Chapter 9 (class extension). You will not have to write any code. You may have to describe what code that I give you does. It will be closed book.

Sample quiz questions (and answers):

  1. What can black-box testing discover about a program that statement-coverage white-box testing won't?
  2. Why unit-test your code as you develop it?
  3. Describe how incremental development works.
  4. What does it mean when you "extend" a class, i.e., write something like:

  5. Consider the following applet (2 classes):

    What is displayed when the applet begins and before the button is pushed?

    What happens every time the button is pushed.

  6. Consider the partial class definition:

    Which, Alpha or Beta, is the subclass?

    Which, Alpha or Beta, is the superclass?


Solutions:

  1. Black-box testing will discover that a program does not meet some requirement. Statement-coverage cannot discover this since the code for meeting some requirement may not even be present and this technique only tests code that is there.
  2. By unit-testing you can gain confidence that small pieces of your code work and hence focus on new pieces of code and not worry about bugs in the already written code.
  3. Incremental testing involves testing successively more complete versions of the final program.
  4. It means that class B has (inherits) instance variables and methods from class A. Hence class B is just like class A, but in the definition of B we may add new instance variables and/or methods, or override existing methods of A.
  5. It initially displays a black circle (diameter 200) in a white square (200x200) and next to it a button labelled "push me".

    When the button is pushed the first time the black circle disappears (leaving just the white square). When the button is pushed again the black circle reappears. Successive button pushes cause the circle to disappear, appear, disappear, appear, etc.

  6. Alpha is the subclass, Beta is the superclass.