KwickCards Java
Dry run with a trace table

ICSE · DRY RUN
Dry run with a trace table
| Step | i | sum |
|---|---|---|
| start | 1 | 0 |
| pass 1 | 2 | 1 |
| pass 2 | 3 | 3 |
| pass 3 | 4 | 6 |
One column per variable, one row per step
Output questions become easy once you dry run them the right way.
Guessing the output from memory leads to mistakes. A dry-run table keeps every change visible, especially for loops, increments and nested conditions.
Notice whether the code uses print() or println(), because that decides whether output appears on the same line.
Practise this method on every output question for two weeks and you will see the difference.
The table traces: int sum = 0; for (int i = 1; i <= 3; i++) sum += i; The loop stops when i becomes 4, so sum is 6.
More on this: free Java lessons
More Java cards
ICSE Java
ISC CS
Java Output
Index the letters of BlueJ
Math methods: watch the return type
Trace a for loop that adds 3Disclaimer. KwickAcademy is free study material for general learning and revision. Parts of it, including the voice-over, are produced with the help of AI tools and may contain errors; if you spot one, please tell us and we will correct it. Syllabus, marks and exam details follow the latest official board publications available to us, and boards can change them at any time, so always confirm against your board's official website and your school. Using this material does not guarantee any marks or result. Board names and trademarks belong to their owners; Kwickprep is not affiliated with or endorsed by any examination board. We never ask for passwords, OTPs or ID numbers. Your progress is saved only in this browser. Full disclaimer · Privacy

