levo

Testing an Object Oriented Application

Dry runs and trace tables

  • 3 things to know
  • AS Unit 1

Overview

Dry run and trace table.

What you need to know

Answer each one before you reveal it.

Your recallNot started
Key term

Why is a hand trace still worth doing when a debugger is available?

Key term

What is a dry run?

Key term

What is a trace table?

Questions from this subtopic

Each one with the model answer underneath.

  1. 1

    What is a dry run?

    Model answer

    A dry run is working through the statements of a program by hand, keeping track of every variable, to establish what the code actually does rather than what it was meant to do.

  2. 2

    What is a trace table?

    Model answer

    A trace table is a table with a column for each variable and a row for each step, filled in by hand as the code is followed so the changing values can be read off.

  3. 3

    When is a dry run more useful than running the program?

    Model answer

    A dry run helps before the code will even compile, and when the fault lies in the logic, because every intermediate value becomes visible instead of only the final output.

  4. 4

    Trace int t = 0; for (int i = 1; i <= 4; i++) { t = t + i; } and state the final value of t.

    Model answer

    The total rises to 1, then 3, then 6, then 10 as i takes the values 1, 2, 3 and 4, so t finishes holding 10.

  5. 5

    Trace int n = 27; int c = 0; while (n > 1) { n = n / 2; c++; } using integer division, and state the final value of c.

    Model answer

    The value of n becomes 13, then 6, then 3, then 1, which takes four passes, so c finishes holding 4.

  6. 6

    A loop written for (int i = 0; i <= 3; i++) is meant to process three array elements with indices 0, 1 and 2. What does a trace show?

    Model answer

    The trace shows i taking the values 0, 1, 2 and then 3, so a fourth pass occurs and uses index 3, which lies one place past the end of the array.

Other ways to work this

The same content, four other ways.

What is inside Levo

Six ways to work the same material.

1Closed book
2Open book
3Closed book

The 3-step method, run for you

Answer cold, learn it, then prove it stuck. Levo tracks the jump between your first attempt and your last.

Software and the Development Environment
Defining Data: Types, Variables and Classes
Program Control Structures
Objects, Classes and Data Structures

Cram a whole paper in one sitting

Sort every topic into what you know and what you do not, then drill only the weak ones.

A null is the of one.
absencepresencetype

Blank Blitz makes facts automatic

Rapid timed gap-fills on the terms and numbers you need to recall without thinking.

AA null means no value has been recorded.
BZero and an empty string are values.
CA null is the absence of a value.

Build It gets the exam shape right

Assemble a full-mark answer from its marking points, in the order an examiner wants them.

An error is the mistake a person made.
TrueFalse

Test It catches misconceptions

Spot the fault in a statement. The traps are the mistakes students actually make.

721941163128510

Brain Breaks between sessions

Short focus games to reset attention, so the next set lands better than the last.

Every question in Testing an Object Oriented Application, on a schedule.

Attempt a question from memory, write the correct version, then attempt it again. Levo records the jump between your first attempt and your last, and brings each question back on the day you are due to forget it.

Or £46 a year, about £3.83 a month. Cancel anytime.