1/33
Looks like no tags are added yet.
Class
A blueprint that defines what fields and methods its objects will have (ex: public class Dog)
Object
One actual instance made from a class using new (ex: Dog d = new Dog();)
Instance
Another word for an object made from a class
Constructor
Special code that runs when an object is created; same name as the class and NO return type, not even void
Overloaded Constructor
A second constructor in the same class with a different parameter list (ex: Dog() and Dog(String name))
Instance Variable / Field
A variable declared in the class but outside any method; each object gets its own separate copy
Parameter
A value passed into a method or constructor, listed inside the parentheses (ex: newName in setName(String newName))
Method
A block of code inside a class that performs an action (ex: public void bark())
Declaration
Stating a variable's type and name without giving it a value (ex: int age;)
Assignment
Giving a value to a variable that already exists, with no type in front (ex: age = 16;)
Declaration + Initialization
Declaring and assigning in one line (ex: int age = 16;)
Variable naming rules
No spaces, first letter lowercase, remaining words capitalized (camelCase) (ex: totalScore)
Method naming rules
No spaces, first letter lowercase, remaining words capitalized (camelCase) (ex: getAge)
Class naming rules
No spaces, first letter capitalized, remaining words capitalized (ex: BankAccount)
camelCase
Naming style where the first word is lowercase and each following word starts with a capital (ex: studentAge)
Getter
A public method that returns a private field's value; returns the field's type and takes no parameters (ex: public int getAge() { return age; })
Setter
A public void method that takes a parameter and assigns it to a private field (ex: public void setAge(int newAge) { age = newAge; })
Encapsulation
Keeping fields private and only allowing access through public methods (getters/setters) so the class protects its own data
OOP
Object-Oriented Programming: organizing code around classes and objects that bundle data (fields) with behavior (methods)
Abstraction
Using an object without needing to know how its code works inside (ex: calling str.length())
Inheritance
When one class builds on another using extends and gets its fields and methods (ex: class SavingsAccount extends BankAccount)
Polymorphism
Different classes responding to the same method call in their own way (ex: Dog and Cat both have speak())
private
Access keyword meaning only code inside the same class can use it; fields are usually private
public
Access keyword meaning any class can use it; getters, setters, and constructors are usually public
this
Refers to the current object; this.name means the field, plain name means the parameter when they share a name
new
Keyword that creates a new object and runs its constructor (ex: new Dog("Max"))
Return type
The type of value a method gives back (int, double, String, etc.), written before the method name
void
Return type meaning the method does not return anything
return
Keyword that sends a value back from a method
static
A field or method shared by the whole class; one copy for all objects, so changing it changes it for every object
Separate copies of fields
Each object has its own copy of instance variables, so changing one object's field does not affect other objects
Methods share fields
All methods in the same object use that object's fields, so a setter's change shows up in the getter
Reference
A variable that points to an object; b = a makes both point to the SAME object, only new makes a separate one
Cube method
public int cube(int n) { return n * n * n; }