Skip to main content

Intro to Computer Science (Java) Study Guide

The whole course, unit by unit

Six units for a first programming course, each topic linked to its own practice set. Each unit explains what to know, how to apply it, what typically goes wrong, and one study move that makes the material stick.

Six units

From first program through decisions, repetition, text, collections, and finally writing your own classes.

No exam

This is a first course. Assessment is by projects and quizzes rather than a national exam.

No prerequisite

Suitable for a student who has never programmed. Middle school through early high school is typical.

Where it leads

AP Computer Science A, which revisits every one of these topics at exam depth.

Units

The six units

Unit 1 is the largest by a wide margin. The rest move faster, and the last one is the bridge into calculus.

1

Unit 1 · Take your time

First Programs and Values

Storing values and doing arithmetic with them. Java asks you to say what kind of value each variable holds, which feels like extra work for about a week and then starts catching your mistakes for you.

VariableTypeintdoubleWhole-number divisionRemainder
2

Unit 2 · Steady

Making Decisions

Teaching a program to choose. The syntax is short; the difficulty is writing conditions that are true exactly when you meant them to be, especially at the edges of a range.

booleanComparisonandornotBranch
3

Unit 3 · Heavy

Repetition

Doing something many times without writing it many times. Most early loop bugs are off by exactly one, which is why counting the iterations deliberately matters more than the syntax.

LoopCounterConditionIterationNested loopRunning total
4

Unit 4 · Steady

Working With Text

Text that you can look inside but never change. Counting from zero takes some getting used to, and almost every early text bug is a position being one off.

PositionIndexPortionSearchUnchangeableTraversal
5

Unit 5 · Heavy

Collections of Values

Holding many values under one name. Arrays are a fixed size; lists grow and shrink. This is also the first place two names can point at the same data, which surprises everyone the first time.

ArrayPositionfor-eachSharingListRemoval
6

Unit 6 · Ends the course

Methods and Classes

Breaking a program into named pieces, then grouping data and behavior together into a class. This is the unit that makes larger programs possible rather than merely longer.

MethodParameterReturnClassObjectConstructor

Mathematical Practices

The habits that run through every unit

Four habits that make a first programming course go well, practised from the first week rather than added later.

1. Predict before you run

Write down what you expect the output to be, then run it. Being wrong is the useful part: the gap between prediction and result is exactly where the learning is, and running first hides it.

2. Trace on paper

Keep a table with one column per variable and one row per line executed. This feels slow for three lines and becomes the only reliable method by ten.

3. Read the error, do not fear it

Java errors name a type, a line, and usually a cause. An error is more informative than silently wrong output, which is why a strict language is easier to learn in than a permissive one.

4. Change one thing at a time

When code misbehaves, change a single line and re-run. Changing three things and getting a different failure teaches nothing about which one mattered.

Assessment

How to answer, not only what to know

Two lists: one for selected-response work, one for anything you have to write out.

Multiple choice

  • Trace with pen and paper rather than reading the code and deciding it looks right.
  • Whenever two whole numbers are divided, check whether the decimal part was meant to survive.
  • For loop questions, write out the first two and the last iteration rather than the whole loop.
  • On String questions, number the characters before answering anything about position.
  • If two options differ only at the first or last item, test exactly that item.

Written work

  • Write what the method should take and give back before writing the body.
  • Test your method on the smallest possible input, including an empty one.
  • Return the answer rather than printing it, unless printing is what was asked for.
  • If you get stuck, write the part you know. Partial work still shows understanding.
  • Use a variable name that says what the value is; it makes your own bugs easier to see.

Study plan

Where the time is best spent

Four moves, in the order that pays off.

1

Get comfortable being wrong

Predict output, be wrong, find out why. Students who run first and reason afterwards progress more slowly, even when their programs work.

2

Make tracing a habit early

Trace short programs by hand for the first few weeks. It is the skill every later unit assumes and the hardest one to add retroactively.

3

Learn integer division properly

This one rule causes more confusion than anything else in the first term. Spend real time on it rather than working around it.

4

Build something you chose

A small program you actually wanted teaches more than a longer exercise you were assigned. Pick something with an input, a decision, and a loop.

5

Write methods before you need them

Splitting a working program into methods, while it still works, is the safest way to learn decomposition.

6

Revisit Unit 1 in Unit 5

Types and boundaries feel abstract at the start and obvious once you are handling arrays. Re-reading early material later is not a step backwards.

Curriculum scope

What this sequence includes

The course teaches one skill from the first day: predict what the computer will do before you run it. Everything else is built on that. Java is strict about types and boundaries, and this guide treats that strictness as a teaching aid rather than an obstacle, because it turns vague mistakes into specific errors.

Algebra and trigonometry core

Essential foundations

  • Variables, types, arithmetic, and why Java cares which type a value is
  • Boolean logic and making a program choose between paths
  • Loops, counters, and totals
  • Strings as text you can inspect but not change
  • Arrays and ArrayList for holding many values at once
  • Methods and classes for organising a program into parts

Breadth beyond the assessed core

Included in this sequence

  • Reading and predicting code written by someone else
  • Debugging by tracing rather than guessing
  • Searching and sorting as first algorithms
  • What it means to store data about people

Varies by course

Compare with the school syllabus

  • Pace. A middle school section may spend a full year on Units 1 to 4; an older beginner may finish all six in a semester.
  • Graphics. Some sections add drawing or simple games as motivation; these are not required by the sequence.
  • Environment. Browser-based editors and full IDEs are both common and neither affects the material.

Glossary

Terms worth being precise about

Variable

A named place that holds one value.

Type

The kind of value a variable holds, such as a whole number, a decimal, or true-or-false.

Whole-number division

Dividing two whole numbers, which cuts off the remainder rather than rounding.

Cast

Telling Java to treat a value as a different type.

Boundary

The exact value at the edge of a range, where most mistakes happen.

Iteration

One pass through the body of a loop.

Running total

A variable that builds up a result across the passes of a loop.

Index

The position of an item, counted from zero.

Method

A named block of code that can be given values and can hand one back.

Return

Handing a value back from a method to whatever called it.