AP CSA Free Digital Textbook Section 1 1 Why Programming Why Java
Can You Think Like a Computer?
Predict what this code will output. Use your intuition!
int mystery = 10;
mystery = mystery + 5;
mystery = mystery * 2;
System.out.println(mystery);
What number will be printed?
Why Programming? Why Java?
Discover why programming is the ultimate superpower for problem-solving, and why Java is your gateway to mastering computer science.
- Understand what programming is and why it matters
- Distinguish between algorithms and programs
- Explain why Java is used for AP Computer Science A
- Recognize the difference between high-level and low-level languages
What is Programming?
At its core, programming is the art of giving precise instructions to a computer. But here's the secret: programming isn't really about computers at all. It's about problem-solving.
Think of programming like writing a recipe. You need to specify every step, every ingredient, and every measurement. Miss one detail, and your dish (or program) won't turn out right.
Why Learn to Program?
Algorithms vs. Programs
Before you write code, you need an algorithm - a step-by-step procedure for solving a problem. You use algorithms every day:
| Everyday Algorithm | Steps |
|---|---|
| Making a sandwich | 1. Get bread 2. Add ingredients 3. Close |
| Dictionary lookup | 1. Open middle 2. Compare 3. Go left/right |
| Getting to school | 1. Leave house 2. Walk to bus 3. Board 4. Exit |
Drag steps into correct order to find the largest number in a list.
From Algorithm to Program
An algorithm describes what to do. A program is an algorithm in a specific language that a computer can execute.
// Find the maximum value in an array int max = numbers[0]; // Start with first for (int num : numbers) { if (num > max) { max = num; // Update if bigger } }
Why Java?
Of all languages, why does AP Computer Science A use Java?
1. Strongly Typed: Catches errors early, teaches good habits.
2. Object-Oriented: The dominant paradigm in modern software.
3. Industry Standard: Powers Android, enterprise systems, millions of apps.
What will this Java code print?
int x = 7; int y = 3; System.out.println(x / y); System.out.println(x % y);
High-Level vs. Low-Level Languages
Languages exist on a spectrum from low-level (close to hardware) to high-level (close to human language):
| Level | Example | Characteristics |
|---|---|---|
| Machine | 10110000 | Binary the CPU executes |
| Assembly | MOV AL, 61h | Human-readable machine code |
| High-Level | Java, Python | Abstracted, portable |
Computers don't "understand" Java. Your code gets compiled to bytecode, which the JVM translates to machine code.
One line has a bug. Click on the line with the error.
Answer all 5 questions to defeat the boss!
VICTORY!
You've mastered Section 1.1!
Get in Touch
Whether you're a student, parent, or teacher — I'd love to hear from you.
Just want free AP CS resources?
Enter your email below and check the subscribe box — no message needed. Students get daily practice questions and study tips. Teachers get curriculum resources and teaching strategies.
Message Sent!
Thanks for reaching out. I'll get back to you within 24 hours.
Prefer email? Reach me directly at [email protected]