7m left·0%
Reading Time: 7 min
Last Updated: June 15, 2026
Main Ideas: 4
Reading Time: 7 min
Last Updated: June 15, 2026
Main Ideas: 4

Topic 1.1 Notes – Introduction to Algorithms, Programming, and Compilers

Verified for 2027 AP® Computer Science A Exam
Read aloud
Programming in Java starts with algorithms and ends with the computer actually running your code. In between, your program is compiled, checked for certain errors, and executed by the Java Virtual Machine. Topic 1.1 is about understanding that whole flow and the different kinds of mistakes that can happen along the way.

1. What an Algorithm Is

An algorithm is a step-by-step process for solving a problem or completing a task.

Think beyond code. An algorithm for “finding the tallest student in a class” might look like:

  1. Start with the first student as the tallest so far.
  2. Compare each remaining student’s height to the current tallest.
  3. If someone is taller, update who is tallest.
  4. After checking everyone, report the tallest.

Notice what makes this an algorithm:

  • It has a clear starting point.
  • It follows a defined sequence of steps.
  • It executes one step at a time.
  • It has a clear ending point.
  • It works for the general case (any class), not just one specific group.

Sequencing

Sequencing means steps happen in a specific order, one at a time.

If you change the order, you change the result. For example, you can’t compare heights before you decide who you’re comparing to. Computers are strict about this. They execute instructions exactly in the order written unless you explicitly tell them otherwise (which you’ll learn later with conditionals and loops).

On quizzes, you might be asked to:

  • Spot when steps are out of order.
  • Identify a missing step.
  • Rewrite a vague process to make it precise.

Representing Algorithms

You should be comfortable expressing algorithms in:

  • Written language (clear, numbered steps)
  • Diagrams, such as flowcharts

Here’s a simple flowchart that represents an algorithm for checking whether a number is positive:

Flowchart for checking if a number is positive

Even if you never draw one by hand on the AP exam, you should be able to read this and trace the logic from start to finish.

Strong representations:

  • Use precise language
  • Avoid vague phrases like “do something”
  • Account for all expected inputs

Weak ones:

  • Skip steps
  • Only work for one example
  • Assume the reader fills in missing logic

On the AP exam, they love giving you a short written algorithm and asking what it does, or asking you to turn one into Java code.

2. From Java Code to Execution

When you click “Run,” more is happening than you might think.

The Compilation and Execution Process

Here’s the full path from your code to actual output on the screen:

  1. You write Java source code in a .java file.
  2. The javac compiler checks your code for syntax errors.
  3. If there are no syntax errors, the compiler creates bytecode in a .class file.
  4. The Java Virtual Machine (JVM) loads and runs that bytecode.
Study guide illustration

Java compilation and execution pipeline

The diagram shows this pipeline step by step, from your .java file to machine code and finally program output.

Important details:

  • If there’s a syntax error, no .class file is created.
  • The program cannot run until syntax errors are fixed.
  • Java uses bytecode so it can run on different systems. Each system has its own JVM.

IDE vs Text Editor

You can write Java in a basic text editor. An IDE (Integrated Development Environment) just gives you tools:

  • Syntax highlighting
  • Error underlines
  • Built-in compiler
  • Run and debug buttons

The IDE doesn’t replace the compiler. It just uses it behind the scenes.

3. Types of Programming Errors

You need to quickly classify errors. This shows up constantly in multiple-choice questions.

a. Syntax Errors

A syntax error breaks Java’s grammar rules.

Examples:

  • Missing semicolon
  • Misspelled keyword
  • Mismatched braces

Detected by the compiler.
If it doesn’t compile, it’s syntax.

b. Logic Errors

A logic error means your algorithm is wrong.

  • The program compiles.
  • The program runs.
  • The output is incorrect.

Examples:

  • Dividing by the wrong number
  • Wrong loop bounds
  • Incorrect condition in an if statement

The compiler cannot catch these. You find them by testing and tracing.

If it runs but gives the wrong answer, that’s logic.

c. Run-Time Errors

A run-time error happens while the program is executing.

  • It compiles.
  • It starts running.
  • It crashes.

Examples:

  • Accessing an invalid array index
  • Dividing by zero

These usually cause the program to terminate abnormally.

Exceptions

An exception is a specific type of run-time error caused by an unexpected situation.

Examples:

  • ArrayIndexOutOfBoundsException
  • NullPointerException

The compiler cannot predict all exceptions. They interrupt normal execution when they occur.

4. How to Classify Errors on the Exam

Use this mental checklist:

  1. Does it compile?
    • No → Syntax error
  2. Does it crash during execution?
    • Yes → Run-time error
  3. Does it run but produce incorrect output?
    • Yes → Logic error

Common mix-ups:

  • Calling an out-of-bounds access a syntax error. It’s run-time.
  • Thinking the compiler catches logic mistakes. It doesn’t.

Lock in the pattern:

  • Syntax = grammar problem
  • Logic = algorithm problem
  • Run-time = execution problem
  • Exception = specific run-time interruption

Key Takeaways

An algorithm must work for the general case and execute steps in a precise sequence.
Java source code becomes bytecode through the compiler before the JVM runs it.
If the program won’t compile, it’s always a syntax error.
If it compiles and crashes, it’s a run-time error.
If it compiles and runs but gives the wrong result, it’s a logic error.

AP® is a trademark registered by the College Board, which is not affiliated with, and does not endorse this website.

Notes

1 credit used · 5/5 remaining