
This course includes our updated coding exercises so you can practice your skills as you learn.
See a demo
Learn how Java source code is compiled into bytecode and executed by the Java Virtual Machine. Understand compilation, execution, and the distinction between compile-time and runtime.
Install the Java Development Kit and IntelliJ Community edition, connect the JDK to a new AP Computer Science A project, and navigate the src folder for future Java programming.
Create and run your Java program by writing a HelloWorld class with a main method that prints hello world to the console, while learning file and class name matching rules.
Explore how print statements work in Java, comparing System.out.println and System.out.print, learn about string literals, double quotes, and how the cursor moves between lines to format console output.
Identify compile-time errors in Java and distinguish them from runtime errors with real-time IDE feedback. Fix syntax issues like missing semicolons and unmatched braces to enable successful compilation into bytecode.
Explore data types in Java, including int and double for numbers, boolean for logical values, and string for text, plus primitive versus reference types and basic operations.
Explore arithmetic operators in Java for int and double values, including plus, minus, asterisk, slash, and percent, and learn how expressions, literals, and operator precedence evaluate at runtime.
Discover how java determines the type and value of arithmetic expressions at compile time, guided by operand types, with int and double rules, numeric promotion, and integer division.
Explore how the modulo operator returns the remainder of integer division in Java, with examples like 10 modulo 3 and 8 modulo 2, and distinguish quotients from remainders.
Explore runtime errors in Java as the JVM executes bytecode, causing an arithmetic exception on division by zero, halting execution, with integers versus doubles producing different outcomes.
Explore how variables work in Java by creating and initializing memory slots in the JVM, declaring and assigning int, double, boolean, and string variables.
Learn how to declare and access variables in Java, calculate a sale price from an original price using expressions, and the importance of initializing variables to avoid compile-time errors.
Modify the price variable after initialization using assignment statements; the expression is evaluated first, allowing price to become 4.5 or 9.0 when doubled.
Practice using variables in a Java program by creating a variables class with a main method, declaring a double price initialized to 3.5, printing, updating to 4.5, and printing again.
Learn how Java identifiers name variables and classes with case sensitivity, allowed characters, including $ and _, and restrictions like not starting with digits or spaces.
Declare constants with the final keyword to prevent modification after initialization, using all caps with underscores for final variable names; illustrates using pi to compute circle area.
Explains compound assignment operators in Java, showing how they combine arithmetic with assignment, and highlights increment and decrement operators used in leap year examples.
Explore type casting in Java: convert between double and int, understand the casting operator, truncation of decimals, and how casting interacts with operator precedence.
Rounding double values to the nearest integer uses the int casting operator, adding 0.5 for positives and subtracting 0.5 for negatives.
Learn widening and narrowing casting in Java, including automatic int to double conversion and manual double to int casting, and why 32-bit vs 64-bit types matter.
Explore the boolean data type and boolean algebra foundations, learn true and false literals in Java, and study relational and logical operations using boolean operands.
Boolean variables represent two states, such as light on/off or having a coupon, by storing true or false values and using prefixes like is or has to describe the state.
Master relational operators in Java, including less than, greater than, less than or equal to, greater than or equal to, equal to, not equal to, applied to int, double, and boolean operands.
Relational operator precedence places first group of relational operators after arithmetic, producing boolean results. The second group (equal to and not equal to) is evaluated afterward; use parentheses for clarity.
Explore how relational operators compare variables to values, yielding booleans from cost greater than 30 and seats booked equals max capacity, and learn operand order for 1 to 10 inclusive.
Explore how boolean values drive logical operations using the not operator, the and operator, and the or operator, and learn how unary and binary operators form boolean expressions.
Create truth tables for not, and, and or operators by listing boolean operands like A and B, exploring all true/false combinations and the 2^n case rule.
Examine short circuit evaluation in Java for and and or operations, where the left operand A is evaluated first and B is skipped when the result is already determined.
Explore the full Java operator precedence, from parentheses to boolean operators, and learn how short-circuit evaluation in and/or operations can alter evaluation order and prevent arithmetic exceptions.
Explore how to use logical operators to combine relational expressions, avoid compile-time errors, and evaluate conditions like numbers between one and ten inclusive and extreme weather conditions.
Explore how to use boolean variables and expressions to determine member and non-member discounts in Java, using and not operators and promoting readable boolean checks.
Explore De Morgan's laws and how not A and B equals not A or not B; not A or B equals not A and not B, via truth tables.
Write an if statement in Java to display a 10% off message when amount spent is at least 100 and always print thank you for shopping with us.
Use an if-else statement to determine ticket fare by age, giving free fare for under 18 or 65 and older, otherwise charging 2.50.
Illustrate using an if-else-if ladder in Java to display gold or silver member messages from a loyalty points system, printing only one tier.
Master multi-way selection by chaining if, else if, and else statements, where boolean tests run top-to-bottom and only one block executes, with gold, silver, bronze, and general member tiers.
Order boolean conditions from highest to lowest to ensure correct tier. When points reach 1001, check 800 first, then 500, then 300 to print gold.
Examine how many blocks execute in if, if else, and if else if statements, and why compiler behavior differs from runtime, with a coffee shop example about member tier initialization.
Learn how variable scope works in Java. A variable is usable from its declaration to the end of its block and cannot be accessed outside or redeclared in that scope.
Learn how variable scope and lifetime in Java dictate when a memory slot exists, as declarations create slots, blocks end their lifetimes, and out-of-scope variables trigger compile-time errors.
Learn how to use iteration statements in Java to execute a statement a specified number of times, replacing multiple prints with a single, scalable approach to print Hello.
Learn the while loop syntax, including the while keyword, a boolean expression in parentheses, and a loop body, and how it repeats while the expression is true.
Define an iteration as one execution of the loop body. See how a while loop re-evaluates the boolean expression to enter the next iteration.
Explore while loops with an example starting at eight, halving while divisible by two using modulo checks. Track variable changes with a trace table and observe prints and iterations.
The loop variable controls how many times the while loop runs, and the boolean expression must become false to terminate; if the variable never changes, you have an infinite loop.
Master the for loop syntax with start, boolean, and step parts, and the loop header versus body. The example runs three iterations, printing hello each time.
Learn about variable scope and lifetime in for loops, focusing on declaring i in the loop header. Move the declaration outside to extend scope and print i after the loop.
Explain the scope and lifetime of loop-body variables, and how declaring sum before the loop extends its lifetime. See that num = 3 yields a final sum of 6.
Examine how for loops and while loops can implement the same behavior, with for loops ideal when you know the iteration count, and while loops guided by a boolean condition.
Define object oriented programming as a paradigm and show how Java centers on objects. Build a library program design with a book class, illustrating objects and classes.
Define a book class with title, author, and is on loan as instance variables, stored at the top of the class, describing each object's state and its internal scope.
Create constructors to initialize a book object with custom title and author, using parameters to set instance variables and defaulting is on loan to false.
Create a library management system main class and instantiate book objects with a constructor by passing title and author strings to initialize fields.
Access an object's instance variables using dot notation, as shown with book one title. Show that instance variables belong to an object and can be printed in main via expression.
Static variables belong to the class, not objects, are shared by all instances, and the count increments in the constructor to track created books, accessible via the class name.
Learn how instance methods give behavior to objects, declaring and calling methods, returning values with non void methods, and void methods, demonstrated by a rectangle class with area and scale.
Explore static methods that belong to a class, not an object, and see how add and subtract can be called directly on the calculator class rather than creating objects.
Learn how access modifiers define scope for class elements by using public and private on classes, constructors, variables, and methods, illustrated with a rectangle and canvas example.
Learn how to use arrays to store groceries in a single groceries array, access and modify elements by index, and print all items efficiently with a for loop.
Learn two ways to create arrays in Java: with and without initial elements. Declare and initialize arrays using new with a length or an initial list, and assign by index.
Learn how to traverse arrays by iterating with a for loop, using indices from zero to length minus one to access and print each element.
Design a seat booking system with a 2d array representing six seats in two rows and three columns, initialized to false and accessed as seats[row][col], rows start at zero.
Learn to create 2d arrays in java using two approaches: declaring and initializing without elements (new boolean[2][3], defaults to false) and initializing with elements (3x3 grid of values).
See how Java stores 2D arrays as arrays of arrays and traverse them with nested for loops. Access each element via row and column indices and print the values.
Compare arrays and ArrayLists by showing fixed-length arrays versus dynamic lists, including creating a four-slot array and a growing ArrayList, with length versus size and automatic shifting.
Learn how to create an ArrayList in Java using a generic type parameter E for elements, declare and instantiate it, and set string as the type argument.
Create and manipulate an ArrayList of strings using size, add, get, set, and remove methods, including indexed inserts, while importing java.util.ArrayList.
Explore recursion by defining factorial in terms of itself, establish base cases for zero and positive n, and illustrate computing three factorial through smaller factorials.
Explore recursion by coding a factorial method that calls itself with numb minus one, using a base case of zero that returns one to halt recursion.
Programming can be difficult at first but it doesn't have to be. Using animations and simple explanations, we make difficult concepts easy. Lift off your Computer Science journey here!
This course teaches you Java programming fundamentals using the AP Computer Science A syllabus. We cover all 10 units of the AP Computer Science A course using practical examples and in-depth explanations.
In this course, you will learn:
Key introductory programming concepts such as variables, conditional statements, and loops
Object-oriented programming (OOP) concepts including inheritance
Data structures such as arrays, 2D arrays, and ArrayLists
Complex programming concepts such as recursion
We use animations to provide step by step explanations of how Java programs actually run. By showing what happens when we run a program, students can gain a deeper understanding and appreciation of programming. Each lesson introduces concepts in a concise, easy to understand manner. We recommend taking the course in order as each concept we introduce builds upon the next.
By the end of the course, you will have a strong understanding of Java Programming and have a solid general programming foundation. This will ensure that you are prepared to succeed in the AP Computer Science A course.
If you have any questions or feedback, don't hesitate to contact us. We are happy to help! Thank you for learning with us!