Final Keyword

In Java, the final keyword makes something unchangeable. A final variable becomes a constant that can only be assigned once, a final method cannot be overridden by a subclass, and a final class cannot be extended at all.

Verified for the 2027 AP Computer Science A examLast updated June 2026

What is the Final Keyword?

The final keyword is Java's way of saying "this is locked." What gets locked depends on where you put it. On a variable, final means the value can be assigned exactly once, which is how you create constants like final double TAX_RATE = 0.07;. Try to reassign it later and the compiler refuses to run your code.

On a method, final means no subclass can override it, even if everything else about the class is inheritable. On an entire class, final means no other class can extend it, period. Java's own String class works this way, which is one reason String objects are immutable. So one keyword, three jobs, all with the same theme. Once something is final, its value or definition is set in stone.

Why the Final Keyword matters in AP Computer Science A

The final keyword isn't a named topic in the AP CSA Course and Exam Description, so you won't see a learning objective built around it. But it sits right next to ideas the exam tests constantly. Final variables are how you write constants, a good-style habit in early units on primitive types and variables. Final methods and final classes only make sense once you understand inheritance and overriding, which the CED covers in depth. Knowing what final blocks (overriding, extending, reassignment) sharpens your understanding of what those mechanisms normally allow. That's the real payoff. If you can explain why a final method can't be overridden, you actually understand what overriding is.

How the Final Keyword connects across the course

Constant Variable (Unit 1)

A constant in Java is just a variable declared final, usually written in ALL_CAPS by convention. The compiler enforces what the naming style only suggests. Reassigning a final variable is a compile-time error, not a runtime surprise.

@Override and Method Overriding (Unit 9)

Overriding lets a subclass replace a superclass method with its own version. Declaring a method final shuts that door. If you see @Override on a method that the parent class marked final, the code won't compile. Final is the off switch for the whole overriding system.

Immutable Object (Unit 2)

Final and immutability are cousins, not twins. A final reference to an object means the reference can't point somewhere new, but the object's internal state can still change unless the class itself is designed to be immutable, like String. Final freezes the variable, not necessarily the data.

Inheritance and Class Hierarchies (Unit 9)

Inheritance is all about extending classes to build hierarchies. A final class opts out entirely, so it's always a leaf at the bottom of any hierarchy. Recognizing this helps you reason about which class designs are even legal in an FRQ-style scenario.

Is the Final Keyword on the AP Computer Science A exam?

The final keyword sits at the edge of the AP CSA Java subset, so it's not a star of the exam. No released FRQ has required you to write or analyze final yourself. Where it can matter is conceptually. Multiple-choice questions about inheritance and overriding assume you know the normal rules, and final is the exception that proves you know them. You might also see constants written with final in provided code, and you're expected to treat them as fixed values when tracing. The practical move for the exam is simple. Recognize final when you read it, know it means "cannot change or override," and never write code on an FRQ that tries to reassign a constant.

The Final Keyword vs Immutable Object

Final and immutable feel like the same idea, but they lock different things. A final variable locks the variable itself, meaning you can't reassign it. An immutable object locks the data inside the object, meaning its state can never change after creation. You can have a final reference to a mutable object (the variable always points to the same ArrayList, but you can still add to that list), and you can have a non-final variable holding an immutable object (you can reassign the String variable, but no individual String ever changes). Final is about the variable. Immutability is about the object.

Key things to remember about the Final Keyword

  • The final keyword does three different jobs depending on placement. It makes a variable a one-time-assignment constant, makes a method un-overridable, and makes a class un-extendable.

  • Reassigning a final variable is a compile-time error, so a constant like final int MAX = 10 can never change while the program runs.

  • A final method can still be inherited and called by subclasses. It just can't be overridden with a new version.

  • A final class, like Java's String, cannot be extended, so it can never be a superclass.

  • A final reference to an object does not make the object immutable. The reference is locked, but the object's contents can still change unless the class itself is immutable.

  • Final isn't a major tested topic on the AP CSA exam, but understanding it strengthens your grasp of constants, overriding, and inheritance, which are tested heavily.

Frequently asked questions about the Final Keyword

What does the final keyword do in Java?

It locks whatever it's attached to. A final variable can only be assigned once (a constant), a final method can't be overridden by subclasses, and a final class can't be extended.

Is the final keyword on the AP Computer Science A exam?

It's not a named topic in the CED and no released FRQ has required it, so don't expect questions centered on it. You should still recognize it in code, since it connects directly to constants and to overriding rules that are tested.

Does making a variable final make the object immutable?

No. Final only locks the reference, not the object. A final ArrayList variable can't be reassigned to a new list, but you can still call add() and remove() on it. True immutability comes from how the class is designed, like String.

Can a final method be inherited?

Yes. Subclasses inherit final methods and can call them normally. What they can't do is override them with their own version. The method's definition is frozen.

What's the difference between final and private?

Private controls who can see or call something (access). Final controls whether it can be changed or overridden (mutability). A method can be private, final, both, or neither, because they answer two completely different questions.