• Accessor Methods: A method that fetches private data that is stored in an object. This method is related to "getting" data.
  • Mutator Methods: A method that controls changes to a variable. This method is related to "setting" data. Usually, a setter method is accompanied by a getter method.
  • Static Variables and Class Variables: A static variable is a variable that has been statically allocated, which means that its lifetime is the entire run of the program. A class variable is a variable that is defined in a class in which only a single copy exists, regardless of how many instances of objects of that class exist.
  • Public, Private, and Protected Access Modifiers: The public access modifier makes it so that the code is accessible for all classes. The private access modifier makes it so that the code is only accessible within the declared class. The protected access modifier makes it so that the code is only accessible in the same package and subclasses.
  • Static Methods and Class Methods: A static method is a method that can be called directly, without the need of creating an object of the class the static method is in. A class method is a method that is bound to a class instead of its object. It can be called by both a class and an object.
  • this Keyword: The this keyword is a reference variable that refers to the current object in a method or constructor.
  • main method and tester methods: The main method serves as an entry point for executing a Java program. It can contain code and call methods to execute. Tester methods are basically instances of main methods being used.
  • Inheritance: An OOP concept that allows subclasses to acquire the properties of a superclass. With inheritance, children classes can inherit the features of a parent class.
public class VocabThree {
    // Initialized private int variable
    private int num;
        
    // Accessor method
    public int getNum() {
        return num;
    }

    // Mutator method
    public void setNum(int numInput) {
        // this keyword
        this.num = numInput;
    }

    // Static variable
    static int staticVar = 7;

    // Class variable
    public int classVar = 7;

    // Protected variable
    protected int protectedVar = 7;

    //Static method
    static void runStatic() {
        System.out.println("Static method is working!");
    }
    //Class method
    public void runClass() {
        System.out.println("Class method is working!");
    }

    // main/tester method
    public static void main(String[] args) {
        // Create an object to access class variables
        VocabThree myObj = new VocabThree();
        System.out.println("Printing Static Variable: " + staticVar);
        System.out.println("Printing Class Variable: " + myObj.classVar);

        runStatic();
        myObj.runClass();
    }
}
VocabThree.main(null);
Printing Static Variable: 7
Printing Class Variable: 7
Static method is working!
Class method is working!
// Inheritance
class SubVocabThree extends VocabThree {
    // main/tester method
    public static void main(String[] args) {
        // Running inherited class method
        SubVocabThree myObj = new SubVocabThree();
        myObj.runClass();
    }
}

SubVocabThree.main(null);
Class method is working!