5m left·0%
Reading Time: 5 min
Last Updated: February 13, 2026
Main Ideas: 6
Reading Time: 5 min
Last Updated: February 13, 2026
Main Ideas: 6

Topic 1.10 Notes – Calling Class Methods

Verified for 2027 AP® Computer Science A Exam
Read aloud
These methods belong to the class itself rather than to individual objects. You’ll practice recognizing them, calling them correctly, and determining what happens when they execute.

What Class Methods Are

A class method is a method declared with the keyword static.

public static int square(int x) {
    return x * x;
}

That static keyword changes everything.

  • The method belongs to the class, not to any specific object.
  • You do not need to create an object to use it.
  • It does not have access to this.
  • It can directly access only:
    • Other static methods
    • static variables

Think of it this way. On the right are utility-style classes whose methods are labeled static. On the left are regular classes where methods belong to individual objects.

Study guide illustration

Class-level (static) methods vs. instance methods

Static methods live at the class level. Instance methods live inside objects created from that class.

If a method doesn’t use instance variables or instance methods, it usually should be static.

How to Call Static Methods

Calling from Outside the Class

The standard format:

ClassName.methodName(arguments);

Examples you should instantly recognize:

Math.sqrt(36);
Math.pow(3, 2);
Integer.parseInt("42");

Notice:

  • No object is created.
  • The class name comes first.
  • The dot operator connects the class to its method.

If you forget the class name outside the defining class, it won’t compile.

Calling from Inside the Same Class

Inside the class where the static method is defined, both of these work:

square(5);              // preferred
Calculator.square(5);   // also valid

The class name is optional because you’re already “inside” the class.

On tests, they love checking this distinction:

  • Outside → class name required
  • Inside → class name optional

Static vs Instance Methods

You need to quickly spot which type a call requires.

Here’s the clean comparison:

Feature Instance Method Static Method
Belongs to Object Class
Called with object.method() ClassName.method()
Access to instance variables Yes No (unless given an object)
Has this Yes No

Example:

public class Counter {
    private int count = 0;

    public void increment() {   // instance method
        count++;
    }

    public static int triple(int x) {  // static method
        return x * 3;
    }
}

Valid calls:

Counter.triple(4);      // correct

Counter c = new Counter();
c.increment();          // correct

Invalid:

Counter.increment();    // error

What Static Methods Can and Cannot Do

Inside a static method:

✔️ You can:

  • Use parameters
  • Call other static methods
  • Create objects
  • Call instance methods using an object reference

❌ You cannot:

  • Use instance variables directly
  • Call instance methods without an object

Classic compile error:

non-static variable cannot be referenced from a static context

That means you tried to use object-level data inside a class-level method.

Determining the Result of a Static Method Call

When tracing:

  1. Evaluate arguments first
  2. Match arguments to parameters
  3. Execute the method body
  4. Return the value (if non-void)

Example:

int value = Math.abs(-8) + 2;

Step through it:

Math.abs(-8) → 8
8 + 2 → 10
value = 10

They often nest calls:

int result = Math.max(5, Math.min(9, 3));

Work inside-out:

Math.min(9, 3) → 3
Math.max(5, 3) → 5

On multiple choice, mistakes usually happen because students rush argument evaluation.

Why main Is Static

public static void main(String[] args)

main must be static because the program starts running before any objects exist. The JVM calls it using the class name.

No object → must be static.

Key Takeaways

static means the method belongs to the class, not objects.
Call static methods with ClassName.methodName() outside the defining class.
Static methods cannot use instance variables unless given an object reference.
Evaluate arguments fully before executing a method when tracing.
If a method does not use instance data, it should probably be static.

AP® is a trademark registered by the College Board, which is not affiliated with, and does not endorse this website.

Notes

1 credit used · 5/5 remaining