The AP Computer Science A 5-hour live stream review is here!Β πŸ’»

Join us on May 5, 2021 for the 🌢️ AP Computer Science A Cram Finale for a last minute review to get all your questions answered!

πŸ“š

All Subjects

Β >Β 

πŸ’»Β 

AP Comp Sci A

Β >Β 

πŸ–₯

Unit 3

3.1 Unit 3 Overview and Boolean Expressions

2 min readβ€’november 16, 2020

Peter Cao

Caroline Koffke


The Big Takeaway Of This Unit

Logic: Using Boolean Expressions and If-Else If-Else statements, we can represent combinational logic and branching decisions.

Unit Overview

Exam Weighting

  • 15-17.5% of the test
  • Roughly 6 to 7 multiple-choice questions
  • A part of FRQ #1, which tests your ability to write methods using control structures, including Ifβ€”Else Ifβ€”Else statements.

Enduring Understanding

This unit introduces the idea of logic, especially when it comes to making decisions in code. We are introduced to boolean statements, which evaluate to a boolean value, either true or false. Using these, we can focus on branching, one of the building blocks of algorithms (the others are sequencing, which is going line by line, and iteration, which we will learn in unit 4). To achieve branching, we will learn Ifβ€”Else Ifβ€”Else statements.

Building Computational Thinking

Using boolean expressions with If-Else If-Else statements allows for the introduction of branching paths and choice to your programs, especially when you want the user to make a decision or when filtering out data. Using these, there are many ways that you can get the same result with the same logic, but we will focus on writing ones that are efficient.

Main Ideas for This Unit

  • Boolean Expressions
  • If-Else Statements
  • Comparing Objects

3.1: Boolean Expressions

Sometimes, we want to compare two numbers or see if two things are equal. To do this, we use boolean expressions, which represent logic and tell whether something is true or false. These are the two values that boolean primitive types can take! There are several operators that can be used to create boolean expressions. Any statement containing these operators will result in a boolean. Here are the operators and what they do:
  • == equals to (two primitive types have the same value)
  • != checks for inequality (not equal)
  • < less than
  • <= less than or equal to
  • > greater than
  • >= greater than or equal to
We will restrict the equality and inequality operators to primitive types for now. We will discuss the equality of objects in 3.7! The four remaining operators only work for numerical types (integers and doubles), but they work exactly like you would expect (ie. 3 < 5 returns true while 3 >= 5 returns false).
You can use boolean statements in conjunction with other operators as well, such as in the following statement:
https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-dN8i6fFxNf4s.png?alt=media&token=1fdf37b7-e098-4ae6-a35c-06141f3c6a8a
This statement is asking if the value represented by a is even or not. If it is even, then we return true. If it is not, we return false.

Was this guide helpful?

πŸ’ͺ🏽 Are you ready for the Comp Sci exam?
Take this quiz for a progress check on what you’ve learned this year and get a personalized study plan to grab that 5!
START QUIZ
FREE AP comp sci a Survival Pack + Cram Chart PDF
Sign up now for instant access to 2 amazing downloads to help you get a 5
Browse Study Guides By Unit
πŸ™
Exam Reviews
πŸ–±
Unit 10: Recursion
βž•
Unit 1: Primitive Types
πŸ“±
Unit 2: Using Objects
πŸ•Ή
Unit 4: Iteration
βš™οΈ
Unit 5: Writing Classes
⌚️
Unit 6: Array
πŸ’Ύ
Unit 7: ArrayList
πŸ’»
Unit 8: 2D Array
πŸ–²
Unit 9: Inheritance
Join us on Discord
Thousands of students are studying with us for the AP Computer Science A exam.
join now