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(...)andSystem.out.print(...) - Loops:
for (int i = 0; i < n; i++),while, the for-each loopfor (int x : values) - Method header: return type, name, parameters with types, for example
static int max(int[] values) - Lengths: array
values.length(no brackets), Stringtext.length()(with brackets), listlist.size() - Comparing strings:
a.equals(b)instead ofa == b, single characters withtext.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:
- Header first. What goes in, what comes out? Here: an
int[]and anintas the limit, and anintcomes back. - Think of an example.
{3, 7, 9, 2, 8}with limit 5 must give 3. - Declare variables before the loop. The counter starts at 0, and it lives outside the loop.
- Write the loop and the condition.
- Don't forget
return. It is the most common reason for lost marks in methods that return a value. - 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 whenxis anint.- A semicolon after
iforfor.if (x > 5);has an empty body, and the block after it always runs. - Missing
return, orreturnin 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.lengthaccesses 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:
- Understand with help. Solve new topics at the computer first, with everything that helps you.
- Write without autocomplete. Turn it off. Now you notice which names you really know.
- 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.
- With a time limit. Set a timer. In the exam you only have a few minutes per task.
- 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.
Related articles to learn
- Methods and recursionJava methods explained simply: parameters, return, overloading, varargs and recursion with examples. Plus common mistakes like a missing return.Read article
- ArraysJava arrays explained simply: create them, loop through them, use two-dimensional arrays. With examples and common mistakes like the wrong index.Read article
- StringsJava strings explained simply: substring, charAt, split, equals and StringBuilder with examples. Plus common mistakes like comparing with ==.Read article
More posts
- Exams and testsAP CSA in 3 weeksAP Computer Science A in 3 weeks: what the exam looks like, a week-by-week Java study plan, and how to write free-response code without an IDE.Read more
- Exams and testsAssignments without all-nightersWeekly programming assignments without all-nighters: how to spread one over the week, test your code before you submit and get help without plagiarism.Read more
- Exams and testsOracle Java certificationOracle Java SE 21 Developer exam 1Z0-830: format, topics, who it is for, how to prepare and whether it is worth it. Plus what changes with Java 25.Read more