๐Ÿ“– Crammy ยท All study guides
AP Computer Science A ยท Unit 5

Writing Classes: every key term you need

12 flashcard terms for AP Computer Science A Unit 5, written to match the course framework. Study them here, then drill them as interactive flashcards โ€” free, no account needed.

Study this unit free โ†’
Classes & Objects
Class: blueprint defining fields (data) and methods (functions). Object: instance of class with specific values.
Encapsulation
Hide internal details (private fields), provide controlled access (public methods). Protects data, simplifies interface.
Access Modifiers
public: accessible everywhere. private: accessible only within class. default (no modifier): accessible in package. protected: subclasses can access.
Instance Variables (Fields)
Belong to object; each instance has own copy. Declared in class; initialized in constructor or at declaration.
Class Variables (static)
Shared by all instances. Declared static. Access via ClassName.variable. Example: counter tracking total objects created.
Instance Methods
Act on object; access this (current object). Example: getName() returns object's name.
Class Methods (static)
Act on class, not instance. No access to 'this' or instance variables. Example: Math.sqrt(), Integer.parseInt().
Constructors
Initialize object; same name as class. Can have parameters. Default no-arg constructor provided if none written.
this Keyword
Refers to current object. Used to distinguish instance variables from parameters: this.name = name;
Getters & Setters
Getter: public method returning field (getName()). Setter: public method modifying field (setName(String)). Control access/validation.
Method Overloading
Multiple methods same name, different parameter types/number. Example: int add(int, int) and double add(double, double).
Unit 5 Summary
Classes combine data (fields) and behavior (methods). Encapsulation controls access. Constructors initialize; getters/setters manage data.
Turn these into flashcards & quizzes โ†’

More AP Computer Science A guides