---
title: "Constructor Header — AP CS A Definition & Exam Guide"
description: "A constructor header is the declaration line giving the access modifier, class name, and parameters. No return type allowed, a detail AP CSA loves to test."
canonical: "https://fiveable.me/ap-comp-sci-a/key-terms/constructor-header"
type: "key-term"
subject: "AP Computer Science A"
unit: "Unit 3"
---

# Constructor Header — AP CS A Definition & Exam Guide

## Definition

In AP Computer Science A, a constructor header is the first line of a constructor declaration, made up of an access modifier (usually public), a name that exactly matches the class name, and a parameter list. Unlike a method header, it has no return type, not even void.

## What It Is

The constructor header is the top line of a [constructor](/ap-comp-sci-a/unit-1/creating-and-storing-objects/study-guide/rUOTKl6Ih5noXJ0GtxJF "fv-autolink"), the part before the curly braces. It has three pieces: an [access modifier](/ap-comp-sci-a/key-terms/access-modifier "fv-autolink") (almost always `public` on the AP exam), a name that must match the class name exactly, and a parameter list in parentheses. For a class called `Player`, the header looks like `public Player(String n, int s)`.

What makes it special is what's *missing*. A constructor header has no return type. Not `int`, not `String`, not even `void`. That's because a constructor's job, per EK 3.4.A.2, is to set the initial state of a new object. When you call it with `new`, Java allocates memory for the object and hands back the object reference automatically. The [parameters](/ap-comp-sci-a/unit-4/recursion/study-guide/p4D3YegZCLwQ3KJVvsd4 "fv-autolink") in the header are how outside data gets in to initialize the instance variables. If you accidentally write `public void Player(...)`, Java reads that as a regular method that happens to share the class's name, and `new Player(...)` will fail because no matching constructor exists.

## Why It Matters

Constructor headers live in [Topic 3.4](/ap-comp-sci-a/unit-3/constructors/study-guide/3Ez6zzak2wRwMrTj2ZQk "fv-autolink") (Constructors) in [Unit 3](/ap-comp-sci-a/unit-3 "fv-autolink"): Class Creation, supporting learning objective 3.4.A. The CED expects you to write constructors that initialize every instance variable, and you can't do that if the header is wrong. A bad header means the constructor never runs, or never exists at all.

This matters beyond Unit 3 because every class-design FRQ on the exam starts with you reading or writing class declarations. Knowing instantly that `public Temperature(double d, String s)` is a constructor while `public void temperature(double d, String s)` is a method makes you faster and more accurate on both MCQs and FRQs.

## Connections

### [Attribute (Unit 3)](/ap-comp-sci-a/key-terms/attribute)

The header's [parameter list](/ap-comp-sci-a/key-terms/parameter-list "fv-autolink") exists to feed values into the object's attributes. Per EK 3.4.A.1, attributes are the instance variables that define an object's state, and the constructor body copies parameter values into them.

### Method headers (Unit 3)

A [method header](/ap-comp-sci-a/key-terms/method-header "fv-autolink") and a constructor header look almost identical, which is exactly why the exam tests the difference. The method header has a return type and (by convention) a lowercase name; the constructor header has no return type and matches the class name exactly.

### Object instantiation with new (Unit 1)

When you write `new Player("Ana", 0)`, Java matches your arguments against the parameter list in a constructor header. The number, order, and types of arguments must line up with the header, or the code won't [compile](/ap-comp-sci-a/key-terms/compile "fv-autolink").

### [Constructor overloading (Unit 3)](/ap-comp-sci-a/key-terms/constructor-overloading)

A class can have multiple constructors as long as each header has a different parameter list. Java picks which one to run based on which header matches the arguments you pass to new.

## On the AP Exam

Multiple-choice questions love to show you a class with a subtly broken constructor and ask why it "does not work as intended." Two classic traps show up in practice questions on this topic. First, a header written with a return type, like `public void Temperature(double d, String s)`, which turns the constructor into an ordinary method so `new Temperature(98.6, "F")` won't compile. Second, a correct header followed by a body that re-declares local variables (like `String name = n;`), which shadows the instance variables and leaves the object's state uninitialized. On FRQs, class-design questions like 2017 FRQ Q2 ask you to write an entire class, and the constructor header is one of the first lines graders check. Get the access modifier, exact class name, and parameter types right, and skip the return type.

## constructor header vs Method header

A method header always declares a return type (including void) and conventionally uses a lowercase name. A constructor header has no return type at all and its name must match the class name exactly. The classic exam trap is `public void ClassName(...)`, which compiles fine but is a method, not a constructor, so calling `new ClassName(...)` with those arguments fails.

## Key Takeaways

- A constructor header consists of an access modifier, a name identical to the class name, and a parameter list, with no return type.
- Adding any return type, even void, to a constructor header turns it into a regular method, so new won't find a matching constructor.
- The parameters in the constructor header supply the data used to initialize the object's instance variables (EK 3.4.A.2).
- Arguments passed to new must match the header's parameter list in number, order, and type, or the code won't compile.
- On class-design FRQs, write the header as public ClassName(parameters) and initialize every instance variable in the body.

## FAQs

### What is a constructor header in AP Computer Science A?

It's the declaration line of a constructor, made up of an access modifier (usually public), a name matching the class name exactly, and a parameter list. For example, public Player(String n, int s).

### Does a constructor header have a return type?

No. A constructor never declares a return type, not even void. If you write public void Player(...), Java treats it as a regular method and new Player(...) will fail to compile.

### How is a constructor header different from a method header?

A method header includes a return type and usually a lowercase name, while a constructor header has no return type and must match the class name exactly. That naming-and-return-type combo is the only way Java tells them apart.

### Why does my constructor compile but my object's variables stay unset?

Usually the header is fine but the body re-declares variables, like writing String name = n; inside the constructor. That creates a local variable that shadows the instance variable, so the attribute never gets initialized. Write name = n; instead.

### Can a class have more than one constructor header?

Yes, that's constructor overloading. Each constructor must have a different parameter list in its header, and Java picks the one matching the arguments you pass to new.

## Related Study Guides

- [3.4 Constructors](/ap-comp-sci-a/unit-3/constructors/study-guide/3Ez6zzak2wRwMrTj2ZQk)

## Structured Data

```json
{"@context":"https://schema.org","@graph":[{"@type":"LearningResource","@id":"https://fiveable.me/ap-comp-sci-a/key-terms/constructor-header#resource","name":"Constructor Header — AP CS A Definition & Exam Guide","url":"https://fiveable.me/ap-comp-sci-a/key-terms/constructor-header","learningResourceType":"Concept explainer","educationalLevel":"AP® / High School","about":{"@id":"https://fiveable.me/ap-comp-sci-a/key-terms/constructor-header#term"},"audience":{"@type":"EducationalAudience","educationalRole":"student"},"dateModified":"2026-06-11T05:27:19.753Z","isPartOf":{"@type":"Collection","name":"AP Computer Science A Key Terms","url":"https://fiveable.me/ap-comp-sci-a/key-terms"},"publisher":{"@type":"Organization","name":"Fiveable","url":"https://fiveable.me"}},{"@type":"DefinedTerm","@id":"https://fiveable.me/ap-comp-sci-a/key-terms/constructor-header#term","name":"constructor header","description":"In AP Computer Science A, a constructor header is the first line of a constructor declaration, made up of an access modifier (usually public), a name that exactly matches the class name, and a parameter list. Unlike a method header, it has no return type, not even void.","url":"https://fiveable.me/ap-comp-sci-a/key-terms/constructor-header","inDefinedTermSet":{"@type":"DefinedTermSet","name":"AP Computer Science A Key Terms","url":"https://fiveable.me/ap-comp-sci-a/key-terms"}},{"@type":"FAQPage","mainEntity":[{"@type":"Question","name":"What is a constructor header in AP Computer Science A?","acceptedAnswer":{"@type":"Answer","text":"It's the declaration line of a constructor, made up of an access modifier (usually public), a name matching the class name exactly, and a parameter list. For example, public Player(String n, int s)."}},{"@type":"Question","name":"Does a constructor header have a return type?","acceptedAnswer":{"@type":"Answer","text":"No. A constructor never declares a return type, not even void. If you write public void Player(...), Java treats it as a regular method and new Player(...) will fail to compile."}},{"@type":"Question","name":"How is a constructor header different from a method header?","acceptedAnswer":{"@type":"Answer","text":"A method header includes a return type and usually a lowercase name, while a constructor header has no return type and must match the class name exactly. That naming-and-return-type combo is the only way Java tells them apart."}},{"@type":"Question","name":"Why does my constructor compile but my object's variables stay unset?","acceptedAnswer":{"@type":"Answer","text":"Usually the header is fine but the body re-declares variables, like writing String name = n; inside the constructor. That creates a local variable that shadows the instance variable, so the attribute never gets initialized. Write name = n; instead."}},{"@type":"Question","name":"Can a class have more than one constructor header?","acceptedAnswer":{"@type":"Answer","text":"Yes, that's constructor overloading. Each constructor must have a different parameter list in its header, and Java picks the one matching the arguments you pass to new."}}]},{"@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"AP Computer Science A","item":"https://fiveable.me/ap-comp-sci-a"},{"@type":"ListItem","position":2,"name":"Key Terms","item":"https://fiveable.me/ap-comp-sci-a/key-terms"},{"@type":"ListItem","position":3,"name":"Unit 3","item":"https://fiveable.me/ap-comp-sci-a/unit-3"},{"@type":"ListItem","position":4,"name":"constructor header"}]}]}
```
