Please enable JavaScript to use CodeHS

AP Computer Science A (Mocha)

Description

This lesson discusses printing a message in Java. Instead of extending Karel, students will now extend Console Program to print to the Console.

public class Welcome extends ConsoleProgram
{
    public void run()
    {
      System.out.println("*insert message here* "); 
      System.out.println("*insert message here* "); 
    } 
}
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

This lesson introduces students to the foundational concept of variables in Java, including declaring, assigning, and initializing variables. Through a series of videos, hands-on activities, and exercises, students will explore how different data types work in Java and how to use variables effectively in their programs. The lesson aims to build a strong understanding of variables to support future programming concepts.

Objective

Students will be able to:

  • Understand and explain the purpose of variables in Java
  • Declare, assign, and initialize variables of different data types
  • Identify and correct errors related to variable declarations and assignments
  • Apply variables in simple Java programs to store and manipulate data
Description

This lesson focuses on handling user input in Java. Students will learn how to capture and utilize user inputs through variables and practice with hands-on exercises involving personal data and creative writing. By exploring examples and completing exercises, students will gain practical experience in using user input commands and applying them in various contexts.

Objective

Students will be able to:

  • Capture and use user input in Java programs
  • Understand the different types of user input and when to use each
  • Apply user input to create personalized and creative content
  • Implement user input commands to solve problems and complete tasks
Description

This lesson introduces students to writing programs that solve arithmetic expressions in Java. Students will learn about using variables for computation, handling different data types, and understanding potential pitfalls such as round-off errors and integer overflow. The activities are designed to build a strong foundation in arithmetic operations and computational accuracy in Java.

Objective

Students will be able to:

  • Use Java to perform arithmetic operations and evaluate expressions
  • Understand the significance of data types in arithmetic computations
  • Identify and correct errors related to floating-point arithmetic and integer overflow
  • Write programs to solve arithmetic expressions and simple computational problems
Description

In this lesson, students will explore the concept of type casting in Java, a process where one data type is converted into another. Through various hands-on activities, they will learn how to cast variables between different types, understand the implications of casting, and apply these concepts to real-world problems like rounding numbers and managing data types in mathematical expressions.

Objective

Students will be able to:

  • Understand and apply type casting in Java
  • Differentiate between casting from int to double and vice versa
  • Utilize type casting to solve mathematical problems in Java
  • Analyze the effects of casting on arithmetic operations
Description

In this lesson, students will explore the concept of Boolean logic in Java, focusing on the creation and usage of Boolean variables. Through hands-on activities, they will learn how to work with Boolean expressions, apply them in conditional statements, and understand their significance in controlling program flow. The lesson will emphasize the importance of Boolean logic in decision-making processes, both in programming and in real-world scenarios.

Objective

Students will be able to:

  • Define and create Boolean variables in Java
  • Understand and apply Boolean expressions in conditional statements
  • Utilize Boolean logic to control the flow of a program
  • Analyze how Boolean logic is used in real-world decision-making processes
Description

In this lesson, students will delve into the use of logical operators in Java to create complex conditional statements. By exploring examples and exercises, students will learn how to combine multiple conditions using logical operators like && (AND), || (OR), and ! (NOT) to control the flow of their programs. This lesson emphasizes the importance of logical thinking in programming and how it can be applied to solve real-world problems, such as determining grade ranges or evaluating multiple criteria.

Objective

Students will be able to:

  • Define and use logical operators in Java
  • Combine multiple conditions using &&, ||, and ! to create compound Boolean expressions
  • Analyze and debug logical statements to ensure correct program behavior
  • Apply logical operators to real-world scenarios and problem-solving tasks
Description

In this lesson, students will explore comparison operators in Java, which are essential for making decisions within a program. By learning how to compare variables using operators such as ==, !=, >, <, >=, and <=, students will gain the ability to evaluate expressions and control the flow of their programs based on conditions. Through a series of examples and hands-on exercises, students will understand how comparison operators are used in real-world scenarios, such as grading systems, and apply these concepts to their own programming projects.

Objective

Students will be able to:

  • Define and use comparison operators in Java
  • Write conditional statements that evaluate expressions using comparison operators
  • Apply comparison operators to solve real-world problems and scenarios
Description

In this lesson, students will learn about the structure and application of for loops in Java, an essential programming construct for automating repetitive tasks. By understanding how to create, control, and manipulate loops, students will develop the ability to perform tasks such as counting, summing, and iterating over sequences of numbers. The lesson includes hands-on activities where students will apply for loops to solve real-world problems, enhancing their logical thinking and coding skills.

Objective

Students will be able to:

  • Understand and write basic for loops in Java
  • Modify loop parameters to control the start, end, and increment of the loop
  • Apply for loops to perform tasks such as counting, summing, and iterating over ranges
  • Debug and analyze for loop code to ensure it meets the intended functionality
Description

In this lesson, students will explore the concept of while loops in Java, a fundamental control structure used to repeat a block of code as long as a specified condition is true. Through examples and exercises, students will learn how to create and control while loops, understand the risks of infinite loops, and compare while loops with other loop structures like for loops. By the end of the lesson, students will have a solid understanding of when and how to use while loops effectively in their programs.

Objective

Students will be able to:

  • Understand the structure and function of while loops in Java
  • Write and debug while loops to perform repetitive tasks based on a condition
  • Identify and avoid common pitfalls, such as infinite loops
  • Compare and contrast while loops with for loops in terms of efficiency and use cases
Description

In this lesson, students will explore the use of if statements in Java to control the flow of their programs based on boolean conditions. They will practice implementing and nesting if statements to solve various problems, including determining even and odd numbers, finding minimum values, and evaluating voting eligibility. Through hands-on activities and exercises, students will gain a deeper understanding of conditional logic and its applications in programming.

Objective

Students will be able to:

  • Understand and use if statements to control program flow
  • Implement nested if statements to solve complex problems
  • Use the modulus operator and string methods in conditional expressions
Description

In this lesson, students will explore the concept of the “loop-and-a-half” in Java programming, which involves using a while loop with a break statement to handle specific conditions. They will practice implementing and comparing loop-and-a-half constructs with traditional while loops through examples and exercises. The goal is to understand the efficiency and application of different looping techniques in programming.

Objective

Students will be able to:

  • Understand and implement the loop-and-a-half structure in Java
  • Compare the efficiency of loop-and-a-half versus traditional while loops
  • Apply the loop-and-a-half concept to solve practical programming problems
Description

In this lesson, students will learn about short circuit evaluation in Java, a technique used in logical operations to optimize code performance and prevent unnecessary execution of expressions. By understanding how short circuiting works with logical AND (&&) and OR (||) operators, students will gain the ability to write more efficient and safe code. The lesson includes truth table explorations, examples, and exercises that emphasize the practical applications of short circuit evaluation in programming.

Objective

Students will be able to:

  • Understand the concept of short circuit evaluation in logical operations
  • Apply short circuit evaluation to optimize code performance and prevent crashes
  • Debug and modify existing code to include short circuit evaluation
Description

In this lesson, students will be introduced to De Morgan’s Laws, fundamental rules in logic and Boolean algebra that describe the relationship between conjunctions and disjunctions in expressions. These laws are essential for simplifying and understanding complex Boolean expressions in programming. Through examples, visual aids like truth tables and Venn diagrams, and hands-on exercises, students will learn to apply De Morgan’s Laws to optimize and clarify code.

Objective

Students will be able to:

  • Understand and explain De Morgan’s Laws
  • Apply De Morgan’s Laws to simplify complex Boolean expressions
  • Compare equivalent Boolean expressions using De Morgan’s Laws
Description

In this lesson, students will be introduced to Strings, a fundamental data type in Java used to store and manipulate text. They will learn how to create, compare, and modify Strings using built-in methods, including .equals(). Through practical examples and exercises, students will explore how Strings can be used in programming to handle user input, perform comparisons, and manage text-based data.

Objective

Students will be able to:

  • Create and manipulate String variables in Java
  • Compare Strings using the .equals() method
  • Apply String operations to solve programming problems
Description

In this lesson, students will complete a comprehensive quiz covering the basic Java concepts learned in previous lessons. This quiz is designed to assess students’ understanding of key programming principles and their ability to apply these concepts in a variety of scenarios. The quiz will help students identify areas where they may need additional practice and reinforce their knowledge in preparation for more advanced topics.

Objective

Students will be able to

  • Demonstrate understanding of basic Java concepts through a quiz
  • Apply logical reasoning to solve programming problems
  • Identify areas of strength and areas needing improvement in their understanding of Java