---
title: "AP CSA 1.10: Calling Static Class Methods"
description: "Review how to call static class methods in AP Computer Science A using the class name, dot operator, arguments, and return values."
canonical: "https://fiveable.me/ap-comp-sci-a/unit-1/calling-non-void-method/study-guide/gXkdn6sNrkDRHZsCVN1x"
type: "study-guide"
subject: "AP Computer Science A"
unit: "Unit 1 – Using Objects and Methods"
lastUpdated: "2026-06-09"
---

# AP CSA 1.10: Calling Static Class Methods

## Summary

Review how to call static class methods in AP Computer Science A using the class name, dot operator, arguments, and return values.

## Guide

Class methods, also called static methods, belong to the class itself instead of any [object](/ap-comp-sci-a/key-terms/object "fv-autolink"), so you call them using the class name with the dot operator, like `Math.sqrt(25)`. You know a method is a class method because it has the keyword `static` in its header. For [AP Computer Science A](/ap-comp-sci-a "fv-autolink"), trace the arguments, return value, and class name used in each method call.

## Why This Matters for the AP Computer Science A Exam

This topic shows up across the exam because so many built-in tools, like the `Math` class, are made of class methods. On multiple-choice questions you often have to decide whether a method call is valid and predict what it returns, which means recognizing when you need the class name. For free-response code writing, you will call provided methods and need to use the right name and the right arguments. Getting comfortable with [tracing](/ap-comp-sci-a/key-terms/tracing "fv-autolink") these calls now pays off in every later unit.

## Key Takeaways

- A class method ([static method](/ap-comp-sci-a/key-terms/static-method "fv-autolink")) is tied to the class, not to any single object, and its header includes the keyword `static` before the method name.
- The usual way to call a class method is `ClassName.methodName(arguments)` using the dot operator.
- Inside the class where the method is defined, you can leave out the class name and just call `methodName(arguments)`.
- A non-void class method returns a value, so you store it in a [variable](/ap-comp-sci-a/unit-1/expressions-and-assignment-statements/study-guide/01dr6uUPDAn3SjtK2Psr "fv-autolink") or use it in an [expression](/ap-comp-sci-a/key-terms/expression "fv-autolink"); arguments must match the parameter list in number, order, and type.
- The `Math` class is a familiar example: its methods are all class methods, so you write things like `Math.abs(-42)` without creating any object.

## How to Use This on the AP Computer Science A Exam

### Code Tracing

When you trace a call to a class method, find the [method header](/ap-comp-sci-a/key-terms/method-header "fv-autolink"), match each [argument](/ap-comp-sci-a/key-terms/argument "fv-autolink") to its parameter by position, run the body, and bring the returned value back to where the call happened. A class method call interrupts the normal top-to-bottom flow: the program runs the method, then control returns to the spot right after the call.

```java
public class StaticMethodDemo {
    public static int add(int a, int b) {
        return a + b;
    }

    public static double calculateAverage(double[] numbers) {
        double sum = 0;
        for (double num : numbers) {
            sum += num;
        }
        return sum / numbers.length;
    }

    public static void main(String[] args) {
        // Class name optional inside the defining class
        int sum = add(5, 3);                 // same as StaticMethodDemo.add(5, 3)

        // Must use class name for methods from other classes
        double squareRoot = Math.sqrt(25);   // 5.0
        double power = Math.pow(2, 8);       // 256.0
        int absolute = Math.abs(-42);        // 42

        double[] grades = {90.5, 85.0, 92.3, 88.7};
        double avg = calculateAverage(grades);
        System.out.println("Average: " + avg);
    }
}
```

### Free Response

When the problem gives you a class with class methods, call them with the class name and the dot operator unless you are writing code inside that same class. Since these methods return values, plug the result into a variable or larger expression. Double-check that your arguments line up with the [parameter types](/ap-comp-sci-a/unit-1/creating-and-storing-objects/study-guide/rUOTKl6Ih5noXJ0GtxJF "fv-autolink").

```java
public class Calculator {
    public static int add(int a, int b) {
        return a + b;
    }

    public static int multiply(int a, int b) {
        int sum = add(a, b);              // class name optional here
        int sum2 = Calculator.add(a, b);  // also valid, just longer
        return a * b;
    }
}

public class MathTest {
    public static void main(String[] args) {
        // Outside the defining class, the class name is required
        int result = Calculator.add(5, 3);  // 8
    }
}
```

### Common Trap

A non-void class method only does something useful if you keep its return value. Writing `Math.sqrt(25);` on its own line throws away the answer. Store it or use it in an expression instead:

```java
double root = Math.sqrt(25);            // keep the value
double hypotenuse = Math.sqrt(9 + 16);  // use it directly in an expression
```

## Common Misconceptions

- "You need to create an object to use a class method." You do not. Class methods belong to the class, so `Math.random()` works without ever making a `Math` object.
- "You must always write the class name." Outside the defining class you do need it, but inside the class where the method is written, the class name is optional and you can call the method by name alone.
- "Static and [instance methods](/ap-comp-sci-a/unit-3/static-variables-and-methods/study-guide/zzhHVbXBRCZQ7ng3EeWX "fv-autolink") are called the same way." Instance methods are called on an object with the dot operator, while class methods are normally called using the class name with the dot operator.
- "The class name in a call is just style." When the call is in a different class, leaving out the class name is an error, not just a style choice.
- "Any method can be called as a class method." Only methods declared with `static` in the header are class methods. A method without `static` is an [instance method](/ap-comp-sci-a/key-terms/instance-method "fv-autolink") and needs an object.

## Related AP Computer Science A Guides

- [1.4 Assignment Statements and Input](/ap-comp-sci-a/unit-1/14-assignment-statement-input/study-guide/compoundassignment)
- [1.14 Calling a Void Method](/ap-comp-sci-a/unit-1/calling-a-void-method/study-guide/0RaM4GVOnbikS9dDp971)
- [1.6 Compound Assignment Operators](/ap-comp-sci-a/unit-1/compound-assignment-operators/study-guide/JiszeHqK8F9G6gszbgPL)
- [1.15 String Methods](/ap-comp-sci-a/unit-1/string-methods/study-guide/SltCtk8JxBIgHcMfG6G4)
- [1.1 Why Programming? Why Java?](/ap-comp-sci-a/unit-1/why-programming-why-java/study-guide/lVK6rmrBuug17i1Hna9z)
- [1.11 Using the Math Class](/ap-comp-sci-a/unit-1/using-the-math-class/study-guide/6e652tzJOa5eE5mjPATE)

## Vocabulary

- **class methods**: Methods that are associated with a class rather than with instances of the class, and include the static keyword in their header.
- **dot operator**: The symbol (.) used in Java to access instance methods and properties of an object.
- **static**: A keyword used in a method header to indicate that the method is a class method associated with the class itself, not with individual instances.

## FAQs

### What is a class method in AP Computer Science A?

A class method is a method associated with a class rather than a specific object. In Java, class methods include the keyword static in the method header.

### How do you call a static class method in Java?

Use the class name, the dot operator, the method name, and the arguments: ClassName.methodName(arguments). For example, Math.sqrt(25) calls the sqrt method from the Math class.

### When is the class name optional for a class method call?

The class name is optional when the method call happens inside the same class where the static method is defined. Outside that class, AP CSA expects you to use the class name with the dot operator.

### What does a non-void method return?

A non-void method returns a value of the type named in its method header. You should store that value in a variable, use it in an expression, pass it as an argument, or print it.

### What is a common mistake when calling non-void methods?

A common mistake is calling a non-void method and ignoring the return value. For example, Math.sqrt(25); computes a value but throws it away unless you store or use the result.

### How do you trace a class method call on the AP CSA exam?

Find the method header, match each argument to the correct parameter, run the method body, and replace the call with the returned value. Then continue tracing from the line where the call happened.

## Structured Data

```json
{"@context":"https://schema.org","@type":"FAQPage","inLanguage":"en","mainEntity":[{"@type":"Question","@id":"https://fiveable.me/ap-comp-sci-a/unit-1/calling-non-void-method/study-guide/gXkdn6sNrkDRHZsCVN1x#what-is-a-class-method-in-ap-computer-science-a","name":"What is a class method in AP Computer Science A?","acceptedAnswer":{"@type":"Answer","text":"A class method is a method associated with a class rather than a specific object. In Java, class methods include the keyword static in the method header."}},{"@type":"Question","@id":"https://fiveable.me/ap-comp-sci-a/unit-1/calling-non-void-method/study-guide/gXkdn6sNrkDRHZsCVN1x#how-do-you-call-a-static-class-method-in-java","name":"How do you call a static class method in Java?","acceptedAnswer":{"@type":"Answer","text":"Use the class name, the dot operator, the method name, and the arguments: ClassName.methodName(arguments). For example, Math.sqrt(25) calls the sqrt method from the Math class."}},{"@type":"Question","@id":"https://fiveable.me/ap-comp-sci-a/unit-1/calling-non-void-method/study-guide/gXkdn6sNrkDRHZsCVN1x#when-is-the-class-name-optional-for-a-class-method-call","name":"When is the class name optional for a class method call?","acceptedAnswer":{"@type":"Answer","text":"The class name is optional when the method call happens inside the same class where the static method is defined. Outside that class, AP CSA expects you to use the class name with the dot operator."}},{"@type":"Question","@id":"https://fiveable.me/ap-comp-sci-a/unit-1/calling-non-void-method/study-guide/gXkdn6sNrkDRHZsCVN1x#what-does-a-non-void-method-return","name":"What does a non-void method return?","acceptedAnswer":{"@type":"Answer","text":"A non-void method returns a value of the type named in its method header. You should store that value in a variable, use it in an expression, pass it as an argument, or print it."}},{"@type":"Question","@id":"https://fiveable.me/ap-comp-sci-a/unit-1/calling-non-void-method/study-guide/gXkdn6sNrkDRHZsCVN1x#what-is-a-common-mistake-when-calling-non-void-methods","name":"What is a common mistake when calling non-void methods?","acceptedAnswer":{"@type":"Answer","text":"A common mistake is calling a non-void method and ignoring the return value. For example, Math.sqrt(25); computes a value but throws it away unless you store or use the result."}},{"@type":"Question","@id":"https://fiveable.me/ap-comp-sci-a/unit-1/calling-non-void-method/study-guide/gXkdn6sNrkDRHZsCVN1x#how-do-you-trace-a-class-method-call-on-the-ap-csa-exam","name":"How do you trace a class method call on the AP CSA exam?","acceptedAnswer":{"@type":"Answer","text":"Find the method header, match each argument to the correct parameter, run the method body, and replace the call with the returned value. Then continue tracing from the line where the call happened."}}]}
```
