01
Overview

Method calls: telling Java what to do.

A method call is the moment your program activates a piece of behavior — on an object, on a class, or on a value.

A method call tells Java to run a named block of code. The method may take inputs (parameters), it may produce an output (a return value), and it lives either inside a specific object or inside a class.

In AP CSA, you'll call instance methods on objects (like s.length()) and static methods on classes (like Math.abs(-5)). The dot operator is how you address the method.

Method calls are tested constantly: in tracing problems, in code completion FRQs, and in conceptual MCQs about which receiver — object or class — is correct.

02
Core Concept

Dot notation: who, then what.

The thing to the left of the dot is the receiver; the call to the right is the request.

Instance method call

String s = "Hello";
int len = s.length();

Here s is the receiver — the object whose method is being called. length() is an instance method, called on an object.

Static method call

double root = Math.sqrt(16);

Here the receiver is the class name Math, not an object. sqrt is a static method — it belongs to the class itself.

Methods with no arguments

Even when a method takes no arguments, you still need the empty parentheses: s.length(), not s.length.

Methods that return a value vs void methods

int n = s.length();          // returns a value, store it
System.out.println("Hi");    // void method, no value to store

A void method does its work and returns nothing. You can't assign its result to a variable.

Chaining

String s = "Hello";
String upper = s.substring(1, 4).toUpperCase();

Each method call returns a value; that value can immediately be the receiver of the next call.

03
Key Vocabulary

Vocabulary for every method-call question.

AP CSA uses these terms in MCQ stems and FRQ rubrics.

Vocabulary
  • Method — a named block of code that can be invoked.
  • Method call — the act of invoking a method.
  • Receiver — the object or class to the left of the dot.
  • Argument — the actual value passed into the method when called.
  • Instance method — called on a specific object.
  • Static method — called on the class itself, not on an object.
  • Return value — the value produced by a non-void method.
  • void — a method that returns no value.
04
AP Exam Focus

How method calls are tested.

Wrong receivers and wrong return-value usage are classic traps.

Exam Focus

MCQ patterns to expect:

  • Static vs instance. Calling Math.sqrt(x) is correct; x.sqrt() is wrong because sqrt isn't an instance method.
  • Ignoring return values. s.toUpperCase(); on its own line does nothing visible — Strings are immutable, so s doesn't change.
  • Method calls on null. Throws NullPointerException.
  • Chained calls. Trace from left to right; the result of the first call becomes the receiver of the second.

FRQ tip: always use the exact method signatures given in the problem. Inventing a method name or changing its parameters loses points immediately.

05
Worked Example

Trace chained method calls.

Evaluate each call's return value before moving to the next.

Worked Example AP-style reasoning

Problem. What is printed?

String s = "Computer";
String result = s.substring(0, 4).toUpperCase();
System.out.println(result);

Step 1. Evaluate s.substring(0, 4). This returns the characters at indices 0, 1, 2, 3 — that is, "Comp".

Step 2. Now call .toUpperCase() on "Comp". This returns a new String "COMP".

Step 3. Assign that value to result and print it.

Answer. The program prints COMP.

Why this matters. Notice that s itself is unchanged — it is still "Computer". String methods return new Strings; they never modify the original. Forgetting this is one of the top three AP MCQ mistakes.

06
Common Mistakes

Errors that quietly invalidate your call.

Most method-call errors are about what or how, not syntax.

Watch Out
  • Wrong receiver. Math methods are static and must be called on the class: Math.pow(2, 3), never 2.pow(3).
  • Ignoring return values. s.substring(1) alone does nothing. You must assign or use its result.
  • Missing parentheses. s.length is a compile error; the correct form is s.length().
  • Wrong argument count or order. s.substring(2, 5) takes indices, not lengths.
  • Calling on null. NullPointerException at runtime.
  • Trying to assign a void method's result. int x = System.out.println("hi"); is a compile error.
07
Reference Table

Forms of method call at a glance.

Quick decoding of any call you encounter on the exam.

Method Calls Reference

AP Quick Reference
Form Meaning AP Exam Tip
obj.method() Instance method on an object Receiver must not be null.
ClassName.method() Static method on a class Used for Math and Integer.parseInt.
method() (no dot) Call from inside the same class Implicit receiver is this for instance methods.
a.m1().m2() Chained call Trace left to right.
void method Returns no value Cannot be assigned to a variable.
Non-void method Returns a value Must be used or assigned to matter.
08
Practice Tip

How to read and write method calls fluently.

Speed comes from recognizing patterns, not from memorizing.

Practice Strategy

Use the three practice tools below this lesson in order:

  • MCQ Practice — for each call, name the receiver, the method, and the return type before choosing an answer. This kills static-vs-instance traps.
  • Java Lab — practise calling both instance methods on Strings and static methods on Math. Always store and use the return value.
  • FRQ Practice — when a problem gives you a class with specific methods, use those methods exactly as listed. Don't invent new ones.

If you can answer "who is the receiver?" instantly, you've mastered Java method-call syntax.

09
Section · 09

Practice — attempt these now.

AP-style assessments aligned to this lesson. Time them.

Topic Quiz 30 min 30 marks Pending

AP CSA Topic Practice: Method Calls

AP-style topic practice assessment

Start
FRQ Practice 30 min 18 marks Pending

AP CSA Unit 01 Topic 02 Method Calls FRQ Practice

AP-style topic practice assessment

Start