Objects & methods

AP Computer Science A · Unit 1: Basics

Objects & methods notes

Fact-checked by a second, independent AI review.

Basics of objects and methods in Java: what an object and class are, how to call methods, pass parameters, and read return values.

Object
An instance of a class that has its own state and can perform actions via methods.
Class
A blueprint for objects; defines fields (state) and methods (behavior).
Method
A function defined in a class that performs an action or computes a value; called on an object or class (static).
Parameter and Return
Parameters supply data to a method; return value gives results back to the caller.
Dot notation
Call a method on an object with objectName.methodName(args); access fields with objectName.field.

Remember it: Think: Objects have state (fields) and behaviour (methods) – name = what it is, action = what it does.

Exam tip: Examiners look for correct object.method calls, proper parameter lists, and clear return types; avoid calling non-existent methods and show understanding of object vs class context.

Syllabus checklist

  • Objects & methods: core ideas
  • Terms and typical exam questions for "Basics" in AP Computer Science A (Java
  • College Board)

Practice questions

  1. 1. Which line declares a method in a class?

    Answer checked

    Show answer

    Answer: public void m() { }. A valid method declaration includes a visibility, return type, name, and parameter list with a body.

  2. 2. An object has state stored in ____.

    Answer checked

    Show answer

    Answer: fields. Fields (instance variables) hold the object's state.

  3. 3. A method with return type void can modify an object's fields without returning a value.

    Answer checked

    Show answer

    Answer: True. Void methods may perform actions including changing fields but do not return a value.

  4. 4. For an instance method, you call it on an ____.

    Answer checked

    Show answer

    Answer: object. Instance methods require an object reference to be invoked.

  5. 5. Which expression creates a new instance of a class?

    Answer checked

    Show answer

    Answer: new ClassName(). The keyword new followed by the class name and parentheses creates a new object.

Practise objects & methods as a game

Hearts, combos, streaks and an AI tutor that explains every answer. Start free.

Start free

More from Unit 1: Basics