Class A

In AP Computer Science A, "Class A" is the conventional placeholder name for a subclass: a Java class declared with `class A extends B` that inherits Class B's public methods and fields while adding (or overriding) its own. It's how the exam tests inheritance without a real-world story.

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

What is Class A?

"Class A" isn't a special Java feature. It's the generic name AP exam writers use when they want to test inheritance mechanics without the distraction of a real scenario. When you see public class A extends B, you're looking at a subclass-superclass relationship. Class A is the subclass (the child), Class B is the superclass (the parent), and A automatically gets B's public methods and fields on top of whatever A declares itself.

The key idea is the is-a relationship. Every A object is a B, so an A object can go anywhere a B is expected (a B variable, a B parameter, a B array slot). But it doesn't work backwards. A B object is not an A, because A may have extra methods that B knows nothing about. On the exam these stripped-down hierarchies stand in for the named ones you practice with, like Animal -> Mammal -> Dog -> Poodle. If you can trace what A inherits, overrides, and adds, you can handle any hierarchy they throw at you.

Why Class A matters in AP Computer Science A

Generic A/B class hierarchies live at the heart of the inheritance unit (Unit 9 in Fiveable's AP CSA guides), where you're expected to write subclasses with extends, call superclass constructors with super(), override inherited methods, and reason about polymorphic behavior. The exam loves this setup because it isolates the logic. With no story attached, the only thing being tested is whether you actually understand which class's method runs, which assignments compile, and which casts blow up at runtime. If A extends B makes instant sense to you, declarations like B obj = new A(); stop feeling like trick questions and start feeling automatic.

How Class A connects across the course

Inheritance (Unit 9)

Class A is the textbook subclass. The extends keyword is what creates the relationship, and everything else (what A inherits, what it can override, what it must build with super()) flows from that one line.

Polymorphism (Unit 9)

Because every A is-a B, you can write B obj = new A();. The variable's type (B) controls what the compiler lets you call, but the object's actual type (A) controls which overridden version runs. That split is the single most-tested idea in inheritance MCQs.

Overriding (Unit 9)

If Class A redeclares a method it inherited from B with the same signature, A's version wins whenever the object is actually an A, even if the variable is typed as B. Overriding is what makes polymorphism do anything interesting.

super() (Unit 9)

Class A's constructor has to set up the B part of the object first. Calling super() (explicitly or implicitly) runs B's constructor before A's own code, which is why constructor-order questions always print the superclass output first.

Is Class A on the AP Computer Science A exam?

On the multiple-choice section, generic and near-generic hierarchies show up constantly. You'll get a chain like Animal -> Mammal -> Dog -> Poodle or Fruit -> Apple -> GrannySmith and be asked which declarations compile (a subclass object can be stored in a superclass variable, never the reverse), which method version executes, which cast causes a ClassCastException at runtime, and which calls won't compile because the variable's declared type doesn't have that method. A classic stem gives you Fruit f = new GrannySmith(); and asks what happens when you call f.polish() or cast f to Apple. Another asks you to write a method with a superclass parameter type so it can accept any subclass object. On the FRQ side, you won't see a class literally named "A," but you will complete methods inside a given class (like 2019's APCalendar or 2023's AppointmentBook), and the Class Design FRQ regularly asks you to write a subclass with extends, a constructor that calls super(), and an overridden method. The skill is the same either way: trace the hierarchy, know what's inherited, know what runs.

Class A vs Class B (the superclass)

Students mix up which direction extends points. In class A extends B, A is the subclass and B is the superclass, so A inherits from B, not the other way around. Read it as "A is a B." That means B var = new A(); compiles fine, but A var = new B(); does not, because a plain B object is missing whatever A added. When the exam swaps in real names (Dog extends Animal), the same rule applies: every Dog is an Animal, but not every Animal is a Dog.

Key things to remember about Class A

  • In class A extends B, Class A is the subclass and Class B is the superclass, so A inherits all of B's public methods and fields and can add or override its own.

  • An A object can be stored in a B variable (B obj = new A();) because of the is-a relationship, but a B object can never be stored in an A variable.

  • When a method is overridden in A, the object's actual type decides which version runs, even if the variable is declared as type B.

  • The compiler only lets you call methods that exist in the variable's declared type, so calling A-only methods through a B variable won't compile without a cast.

  • Casting a B variable to A only works if the object really is an A (or a subclass of A); otherwise you get a ClassCastException at runtime.

  • Class A's constructor runs B's constructor first via super(), which is why superclass initialization always happens before subclass initialization.

Frequently asked questions about Class A

What does Class A mean in AP Computer Science A?

It's the generic name exam questions use for a subclass. When you see class A extends B, A is a Java class that inherits Class B's public methods and fields and can declare its own methods, fields, and overrides on top.

In 'class A extends B', which one is the subclass?

Class A is the subclass (child) and Class B is the superclass (parent). Read extends as "is a": every A is a B, so A objects can be used anywhere B objects are expected.

Does Class A inherit private fields from Class B?

Not directly. Private fields and methods in B exist inside every A object, but A's code can't access them by name. A has to go through B's public methods (like getters) or rely on super() to initialize them.

Can I write 'A obj = new B();' if A extends B?

No, that's a compile error. A B object is not an A because it lacks anything A added. The legal direction is B obj = new A();, storing the subclass object in a superclass variable.

Will the AP exam actually use classes named A and B?

Sometimes on multiple choice, yes, though named hierarchies like Animal/Dog/Cat or Fruit/Apple/GrannySmith are more common. FRQs use realistic class names (APCalendar, AppointmentBook), but the inheritance rules you apply are identical.