📚

AP Computer Science A Key Concepts

May 4, 2025

AP Computer Science A: Unit 1

Unit 1.1 Video 1 Notes (Skill 2.B)

System/Class Methods

  • Block Comments: Text between /* and */ is ignored by the compiler. Include name, date, purpose.
  • Class Declaration: Defines the name, start, and end of a class. Class name must match file name (e.g., public class HelloWorld in HelloWorld.java).
  • Main Method: Controls the program's execution (e.g., public static void main (String[] args)).
  • System.out: Object for console output (e.g., System.out.print, System.out.println).

Key Takeaways

  • Use System class methods for console output.
  • System.out.print and System.out.println display output on the monitor.
  • System.out.println moves cursor to a new line, System.out.print does not.

Unit 1.1 Video 2 Notes (Skill 2.B)

String Literals

  • String literals: exact sequence of characters enclosed in quotation marks (e.g., "This is a string literal.").

Unit 1.1 Video 3 Notes (Skill 4.B)

Syntax and Logic Errors

  • Compiler: Translates source code into executable language.
  • Syntax Errors: Examples include system.out.prnt.
  • Logic Errors: Incorrect logic, such as wrong usage of System.out.println.

Unit 1.2 Video 1 Notes (Skill 1.A)

Variables and Data Types

  • Primitive Data Types: Determines size/type of info (e.g., Boolean, int, double).
  • Non-Primitive Types: Can use methods; are usually created by programmers (except String).

Unit 1.2 Video 2 Notes (Skill 1.B)

Variables and Data Types

  • Variables: Names for memory locations holding values.
  • Variable Naming Rules: May include letters, digits, underscores; can't begin with a digit or use reserved words; must be camelCase.
  • Constants: Declared with final keyword and named in ALL CAPS.

Unit 1.3 Video 1 Notes (Skill 2.A)

Expressions and Assignment Statements

  • Literals: Fixed value representations in source code.
  • Arithmetic Operators: +, -, *, /, %.
  • Modulus: Gives remainder of division (e.g., 17 % 5 = 2).*

Unit 1.3 Video 2 Notes (Skill 2.A)

Evaluating Compound Expressions

  • Operator Precedence: Follows PEMDAS, left to right.
  • Division by zero results in ArithmeticException.

Unit 1.3 Video 3 Notes (Skill 1.B)

Initialize/Change Stored Values in Variables

  • Assignment Operator (=): Assigns value to a variable.
  • Operator Precedence: = is last in PEMDAS; works right to left.

Unit 1.4 Video 1 Notes (Skill 2.B)

Compound Assignment Operators

  • += Operator: Adds value to existing value and assigns result back.

Unit 1.4 Video 2 Notes (Skill 2.B)

Increment and Decrement Operators

  • Increment (++) and Decrement (--): Add/Subtract 1 from variable and assign back.

Unit 1.4 Video 3 Notes (Skill 5.A)

Behavioral Description of Compound Assignment

  • Example: int x = 23; x *= 2; x %= 10; displays 3.*

Unit 1.5 Video 1 Notes (Skill 2.B)

Casting and Ranges of Variables

  • Casting: Change data type of a variable (e.g., (int) (2.5 * 3.0) results in 7).*

Unit 1.5 Video 2 Notes (Skill 5.B)

Variable Ranges

  • Int Range: -2147483648 to 2147483647.
  • Double Precision: Up to 14-15 significant digits.