PrepGo

AP Computer Science A Flashcards: Methods: How to Write Them

Written by AP Content Team, Verified for 2026 AP Exams, Last updated: May 2026

Review key ideas with interactive flashcards. This set includes 10 cards to help you master important concepts.

What is an accessor method?
An accessor method is a non-void method that allows objects of other classes to obtain a copy of the value of an instance or class variable.
Card 1 of 10

All Flashcards (10)

What is an accessor method?
An accessor method is a non-void method that allows objects of other classes to obtain a copy of the value of an instance or class variable.
What is the primary purpose of writing methods in a class?
Methods are written in a class to define the behaviors of an object.
What happens when a primitive value is passed as an argument to a method?
The method's parameter is initialized with a copy of the primitive value passed as an argument.
You need to create a method that calculates and provides a student's final grade. Should this be a void or non-void method?
This should be a non-void method because it needs to return a single value (the final grade) to whatever called it.
What is a non-void method?
A non-void method is a method that returns a single value and includes the specific return type in its header instead of the keyword void.
How do we determine the result of calling methods that use primitive values?
We determine the result by developing and executing the code that defines the object's behaviors through those methods.
What is the return characteristic of a non-void method?
A non-void method always returns a single value.
How does the header of a non-void method differ from that of a void method?
A non-void method's header includes the data type of the value it returns (e.g., int, double) in place of the keyword 'void'.
If a method parameter (which is a primitive type) is changed inside the method, does this affect the original argument variable that was passed in the method call?
No, changes to the parameter have no effect on the corresponding argument because the parameter holds a copy of the argument's value.
What is the relationship between an accessor method and a non-void method?
An accessor method is a specific type of non-void method, as its purpose is to return the value of a variable.