Introduction to Programming (Java) — Practice Question Bank
150+ Problems with Fully Worked Solutions
Independent Study Resource
Not affiliated with or endorsed by Yale University
Based on CC BY 4.0 sources and original content
Edition 2026
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
,Table of Contents
1. How to Use This Question Bank
2. Chapter 1: Introduction to Java — 10 problems
3. Chapter 2: Variables, Data Types, and Operators — 12 problems
4. Chapter 3: Strings and Text Processing — 12 problems
5. Chapter 4: Conditionals and Control Flow — 12 problems
6. Chapter 5: Loops and Iteration — 12 problems
7. Chapter 6: Arrays and ArrayLists — 12 problems
8. Chapter 7: Methods and Modular Design — 12 problems
9. Chapter 8: Classes and Objects — 12 problems
10. Chapter 9: Inheritance and Polymorphism — 10 problems
11. Chapter 10: Program Analysis and Debugging — 10 problems
12. Chapter 11: Searching and Sorting — 10 problems
13. Chapter 12: Libraries and I/O — 10 problems
14. Chapter 13: Integration and Review — 8 problems
15. Final Mixed Practice Exam — 20 problems
16. Full Answer Key with Worked Solutions
17. Quick Java Reference
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
,How to Use This Question Bank
This question bank complements the CPSC 1001 Complete Study Guide. Where the guide teaches the
concepts, this bank trains you to apply them under exam conditions.
Recommended workflow
1. Attempt each problem without looking at the solution. Set a timer: 3–5 minutes for code
tracing, 5–10 minutes for writing methods.
2. Check your reasoning. Compare against the worked solution.
3. Re-do missed problems after 48 hours. Spaced repetition is the strongest retention tool.
4. Use the final mixed exam last. It integrates everything under one time limit.
Difficulty Legend
[C] Computational — trace code or apply a rule.
[A] Applied — write a short method or program.
[X] Analysis — explain behavior or find bugs.
[★] Challenge — exam-level, multi-step.
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
, Chapter 1 — Introduction to Java
Problems
1.1 [C] What is the difference between source code and bytecode?
1.2 [A] Write a Java program that prints "Hello, CPSC 1001!" to the console.
1.3 [X] Why must the class name match the filename?
1.4 [C] What does the Java compiler produce?
1.5 [X] What is the role of the JVM?
1.6 [A] Write a program with a `main` method that prints two lines: your name and your major.
1.7 [X] Why is Java described as "write once, run anywhere"?
1.8 [C] What is the entry point of a Java application?
1.9 [★] Explain what happens, step by step, when a Java program is compiled and run.
1.10 [★] Why does Java use both a compiler and an interpreter (JVM)?
Worked Solutions
1.1 Source code is human-readable (.java); bytecode is the compiled intermediate (.class) executed by the
JVM.
1.2
public class Hello {
public static void main(String[] args) {
System.out.println("Hello, CPSC 1001!");
}
}
1.3 The Java compiler expects the public class name to match the .java file name.
1.4 Bytecode (.class files).
1.5 The JVM executes Java bytecode on any platform, giving Java its portability.
1.6 See pattern in 1.2; replace print statement with two `println` calls.
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF