Please enable JavaScript to use CodeHS

Teaching AP® Computer Science A

Description

In this lesson, students will be introduced to and practice using the Java main skeleton that includes the class and main method arguments. They will use the System.out.print and System.out.println commands to print string literals in the editor. This lesson corresponds with AP Computer Science A topic 1.1.

Objective

Students will be able to:

  • call system class methods to generate output to the console
  • recognize the difference between display behavior of System.out.print and System.out.println
  • create string literals
Description

In this lesson, students will learn about variables. Variables allow information to be stored such as numbers, words, or true/false expressions. A variable can be thought of as a box that stores information inside. In Java, variables are composed of three things: a name, type, and value. This lesson corresponds with AP Computer Science A topic 1.2.

Objective

Students will be able to:

  • declare, initialize and assign a value to a variable
  • identify the most appropriate data type category for a particular specification
  • categorize a data type as either primitive or reference
  • declare a final variable
Description

In this lesson, students learn how to use arithmetic expressions in Java. Arithmetic expressions allow the use of mathematical operations within Java. Students will also learn about the modulus operator (%) and how it is evaluated. Such expressions can be used for basic math and even more complex algorithms. This lesson corresponds with AP Computer Science A topic 1.3.

Objective

Students will be able to:

  • evaluate arithmetic expressions in a program code
  • use the modulus operator (%)
Description

In this lesson, students will learn how to use the increment operator (++), the decrement operator (--) and compound assignment operators (+=, ?=, *=, /=, %=). The increment operator (++) and decrement operator (??) are used to add 1 or subtract 1 from the stored value of a variable. The new value is assigned to the variable. This lesson corresponds with AP Computer Science A topic 1.4.

Objective

Students will be able to:

  • Evaluate what is stored in a variable as a result of an expression with an assignment statement
  • Use a compound assignment operators (+=, ?=, *=, /=, %=) in place of the assignment operator
  • Use an increment operator (++) or decrement operator (??) to add 1 or subtract 1 from the stored value of a variable
Description

In this lesson, students will learn how to receive user input with the Scanner class in Java. After creating a new Scanner object, they will learn the commands below that will allow them to take in data from the user.

String name = input.nextLine();
int number = input.nextInt();
double decimal = input.nextDouble();
Objective

Students will be able to:

  • import and initialize a new Scanner to take in user input
  • create variables that take the assigned value of the user input.
  • choose the correct command that will allow the program to receive the input value that corresponds with its desired data type

Enduring Understandings

This lesson builds toward the following Enduring Understandings (EUs) and Learning Objectives (LOs). Students should understand that?

  • EU (Var-1) To find specific solutions to generalizable problems, programmers include variables in their code so that the same algorithm runs using different input values. (LOs 1.A, 1.B)
Description

In this lesson, students will learn how to change the data type of a value through the process of casting. They will also use casting to help round double values to the closest integer value. Students will explore the range of variables allowed in Java and understand integer overflow when a value outside of this range is attempted. This lesson corresponds with AP Computer Science A topic 1.5.

Objective

Students will be able to:

  • Evaluate arithmetic expressions that use casting
  • Understand that integer values in Java are stored using a finite amount (4 bytes) of memory. Therefore, an int value must be in the range from Integer.MIN_VALUE to Integer.MAX_ VALUE inclusive
  • Understand when an expression evaluates to an int value outside of the allowed range, an integer overflow occurs
  • Recognize and use implicit casting
  • Use casting to round to the nearest integer
Description

In this lesson, students are introduced to classes and objects. These are the foundations of object oriented programming.
Students will learn about objects that have state and behavior, and classes which are the templates for creating objects. This lesson corresponds with AP Computer Science A topic 2.1.

Objective

Students will be able to:

  • Explain the relationship between a class and an object
  • Create classes with instance variables
Description

In this lesson, students will create and use constructors. The constructor, or signature of a class, allows for the creation of a new object. Students will create objects by calling constructors with parameters. Parameters are values that are passed into a constructor. These are referred to as actual parameters. This lesson corresponds with AP Computer Science A topic 2.2.

Objective

Students will be able to:

  • Create and use constructors
  • Create objects by calling constructors with parameters
Description

In this lesson, students are introduced to method overloading. This is when several different methods are written, each with the same name. As long as each method’s parameter list is different, the same method name can be used multiple times! This lesson corresponds with AP Computer Science A topic 2.2.

Objective

Students will be able to:

  • Explain the purpose of method overloading
  • Create classes that overload methods
  • Explain how null objects do not point to any particular object data
  • Create programs that use other classes as a client to solve a specific problem
Description

In this lesson, students will take a deeper look into creating and calling the methods of a class. Methods are procedures that define and allow for control of the behavior of an object. Once an object is instantiated, the instance variables can be used across the different methods that are created. Students will also learn about procedural abstraction for methods that can be used without knowing all of the underlying details and code. This lesson corresponds with AP Computer Science A topic 2.3.

Objective

Students will be able to:

  • Create and call class methods
  • Call non-static void methods without parameters
Description

In this lesson, students will build on what they have learned and discover how to call a void method with parameters. Just as constructors can have parameter values, methods can have formal parameters that affect the state of the object as well. Methods can also be overloaded just like constructors! This lesson corresponds with AP Computer Science A topic 2.4.

Objective

Students will be able to:

  • Call non-static void methods with parameters
Description

In this lesson, students will learn how to call a non-void method and return a value from a method by using the keyword return. The return keyword returns a variable or value back to the existing program so it can be used further along in the program. This lesson corresponds with AP Computer Science A topic 2.5.

Objective

Students will be able to:

  • Create and call non-void methods with parameters and return values
Description

In this lesson, students will learn about the immutability of Strings as objects. Once a String object is created, it cannot be changed or manipulated. The only way to change a String value is to reassign the variable with a different String value. Students will also practice String concatenation using operators such as + and += and use escape sequences such as \? and \n. This lesson corresponds with AP Computer Science A topic 2.6.

Objective

Students will be able to:

  • Create String objects for a String class
  • Concatenate Strings using operators and escape sequences
Description

In this lesson, students will look at Strings as a sequence of characters and utilize String methods from the java.lang package. Students will learn about packages, libraries and documentation. The following String methods will be examined in this lesson:

name.length() 
name.substring(2, 6)
name.indexOf(?d?)
name.equals(?Karel?)
name.compareTo(?Karel?)

This lesson corresponds with AP Computer Science A topic 2.7.

Objective

Students will be able to:

  • Call String methods for a String class
  • Explain the importance of APIs, documentation and packages in Java

Enduring Understandings

This lesson builds toward the following Enduring Understandings (EUs) and Learning Objectives (LOs). Students should understand that?

  • EU Var-1 To find specific solutions to generalizable problems, programmers include variables in their code so that the same algorithm runs using different input values. (LO’s 1.E, 1.D)
  • EU Mod-1 Some objects or concepts are so frequently represented that programmers can draw upon existing code that has already been tested, enabling them to write solutions more quickly and with a greater degree of confidence. (LO’s 1.G, 1.F, 1.C)
Description

In this lesson, students will learn about Boolean expressions and relational operators. Relational Operators are constructs in programming that allow for the comparison of the values of two expressions. This lesson corresponds with AP Computer Science A topic 3.1.

Objective

Students will be able to:

  • Evaluate Boolean expressions that use relational operators in program code
Description

In this lesson, students will learn about control structures and if statements. If statements are used in programming when there are a set of statements that should be executed only when certain conditions are met. This lesson corresponds with AP Computer Science A topic 3.2.

Objective

Students will be able to:

  • Represent branching logical processes by using flowcharts
  • Use if statements
Description

In this lesson, students will learn how and when to use a while loop. Repetitive code can be avoided by using a while loop. While loops are used to repeat a set of statements until a condition is met. This lesson corresponds with AP Computer Science A topic 4.1.

Objective

Students will be able to:

  • Represent iterative processes using a while loop
  • Execute a return or break statement inside an iteration statement to halt the loop and exit the method or constructor
  • Develop an algorithm
  • Identify if an integer is or is not evenly divisible by another integer
  • Determine a minimum or maximum value
  • Compute a sum, average, or mode
Description

In this lesson. students learn how to use for loops in their programs. The for loop allows students to repeat a specific part of code a fixed number of times.

For loops are written like this:

for(int i = 0; i < 4; i++)
{
    // Code to be repeated 4 times
}

This lesson corresponds with AP Computer Science A topic 4.2.

Objective

Students will be able to:

  • Represent iterative processes using a for loop
Description

In this lesson, students will explore and learn the anatomy of classes. They will take a deeper dive into what the access specifier does, and how it can be used within programs to make data public or private. Students will learn about encapsulation and the responsibility programmers have to choose whether data should be accessible, modifiable, both or neither. This lesson corresponds with AP Computer Science A topic 5.1.

Objective

Students will be able to:

  • Designate access and visibility constraints to classes, data, constructors, and methods
  • Designate private visibility of instance variables to encapsulate the attributes of an object
Description

In this lesson, students will expand their knowledge of constructors. They will create constructors that take objects as a formal parameter. This lesson corresponds with AP Computer Science A topic 5.2.

Objective

Students will be able to:

  • Define instance variables for the attributes to be initialized through the constructors of a class
Description

In this lesson, students will examine writing classes in more detail. It is a good programming practice to avoid altering objects within methods unless the method specifically calls for alterations to the object. Accessor and getter methods make obvious changes to objects, but most methods should not attempt to make changes unless it?s explicitly necessary. This lesson corresponds with AP Computer Science A topic 5.6.

Objective

Students will be able to:

  • Discuss changes to both primitive and reference formal parameters in methods
Description

In this lesson, students will learn about scope and access. The placement of a variable within a program affects the scope of the variable, meaning where it can be used and accessed in a program. Students will learn how to avoid scope and access errors by using method decomposition. This lesson corresponds with AP Computer Science A topic 5.8.

Objective

Students will be able to:

  • Explain where variables can be used in the program code
Description

In this lesson, students will learn about and create arrays. The use of array objects allows multiple related items to be represented using a single variable. This lesson corresponds with AP Computer Science A topic 6.1.

Objective

Students will be able to:

  • Represent collections of related primitive or object reference data using one-dimensional (1D) array objects
Description

In this lesson, students will learn how to traverse arrays. Iteration statements can be used to access all the elements in an array. This is called traversing the array. This lesson corresponds with AP Computer Science A topic 6.2.

Objective

Students will be able to:

  • Traverse the elements in a 1D array