Exams and tests

Java exam on paper: practise writing code without an IDE

Published on October 22, 20265 min read

On your computer your code runs, but in the exam there is a blank sheet in front of you. No autocomplete, no red underline, no "Run" button. Many Java tests at school, college and university are written exactly like this, by hand or in a locked-down exam app. Here you find out what you need to know by heart, how to build a method on paper, and how to practise it on purpose.

Why writing code on paper feels so hard

An IDE does much more for you than you notice. It completes System.out.println, closes brackets, suggests method names and marks errors before you see them. If that is the only way you practise, you often know the solution "roughly". On paper, roughly is not enough.

On top of that, at the computer you experiment. You write something, run it and fix it. On paper you have to think first. That is not a talent, it is practice. And you can train it.

One thing to check first: whether your exam is on paper or on a computer, and which aids are allowed, is decided by your school, university or exam board. If in doubt, ask your teacher or look at past papers from your course.

What you must know without looking it up

You should be able to write these things without thinking:

  • Program skeleton: public class Main { public static void main(String[] args) { ... } }
  • Output: System.out.println(...) and System.out.print(...)
  • Loops: for (int i = 0; i < n; i++), while, the for-each loop for (int x : values)
  • Method header: return type, name, parameters with types, for example static int max(int[] values)
  • Lengths: array values.length (no brackets), String text.length() (with brackets), list list.size()
  • Comparing strings: a.equals(b) instead of a == b, single characters with text.charAt(i)
  • Casting: (double) sum / count, so the division is not done with whole numbers

With arrays and strings, most people mix up exactly these details. If you are unsure, go over arrays in Java and strings in Java. Each article ends with the common mistakes.

How to write a method on paper

A typical task: "Write a method that counts how many values in an array are greater than a limit." Here is how you approach it:

  1. Header first. What goes in, what comes out? Here: an int[] and an int as the limit, and an int comes back.
  2. Think of an example. {3, 7, 9, 2, 8} with limit 5 must give 3.
  3. Declare variables before the loop. The counter starts at 0, and it lives outside the loop.
  4. Write the loop and the condition.
  5. Don't forget return. It is the most common reason for lost marks in methods that return a value.
  6. Walk through your example in your head. Is the result right?
public class Main {    static int countAbove(int[] values, int limit) {        int count = 0;        for (int value : values) {            if (value > limit) {                count++;            }        }        return count;    }
    public static void main(String[] args) {        int[] points = {3, 7, 9, 2, 8};        System.out.println(countAbove(points, 5));    }}
3

Leave space between the lines on your sheet. Then you can add a forgotten line without rewriting everything. You can read more about parameters and return values in methods and recursion.

The most common mistakes on paper

  • = instead of == in conditions. if (x = 5) does not compile when x is an int.
  • A semicolon after if or for. if (x > 5); has an empty body, and the block after it always runs.
  • Missing return, or return in the wrong place, for example in the middle of the loop.
  • Counter declared inside the loop. Then it starts again at 0 on every pass. See loops in Java.
  • Index errors: i <= values.length accesses an index that does not exist.
  • Lost brackets. Indent, even on paper. Every closing bracket goes directly below the start of its line.
  • Wrong type. A method that returns an average usually needs double.

The compiler would report many of these mistakes straight away. On paper you have to find them yourself. That is why it helps to know the messages: the most common Java error messages explains what is behind them.

Practice plan: from the editor to paper

Don't jump straight from the IDE to paper. Go in stages:

  1. Understand with help. Solve new topics at the computer first, with everything that helps you.
  2. Write without autocomplete. Turn it off. Now you notice which names you really know.
  3. Paper first, then type. Write the solution by hand, then type it in character by character and run it. Every error the compiler finds would have cost you marks in the exam.
  4. With a time limit. Set a timer. In the exam you only have a few minutes per task.
  5. Practise reading code. Paper exams often include "What does the program print?". How to train for that is in practising output questions.

Repeat stage 3 until hardly any errors show up when you type your solution in. If you are preparing for a particular exam, these study plans fit: AP Computer Science A in 3 weeks and passing your first programming course.

Practising without autocomplete in Jario

Stages 2 and 3 work well in Jario. In the editor you can turn off autocomplete. Syntax highlighting and error marking stay, but you write the code yourself. "Check" runs tests against your solution, and you see something like "3 of 4 tests passed". So you know straight away whether your paper code not only compiles but is also correct.

When you get a compiler error, the "What does this mean?" hint explains common errors in plain English. The AI tutor knows your task and your code and gives you hints in small steps, but no finished solution. That matters, because nobody helps you in the exam either. You don't need to install anything, the editor runs in your browser.

In short

  • Learn the program skeleton, loops, method headers and the lengths of arrays, strings and lists by heart.
  • Write methods in a fixed order: header, example, variables, loop, return, check in your head.
  • Practise in stages: with help, without autocomplete, on paper and then typed in.
  • Check every paper solution at the computer, so you know your typical mistakes.