AP Computer Science A Practice Quiz: Calling Class Methods
Written by AP Content Team, Verified for 2026 AP Exams, Last updated: May 2026
Test your understanding with short quizzes. This quiz has 9 questions to check your progress.
Question 1 of 9
All Questions (9)
A) class
B) public
C) static
D) void
Correct Answer: C
According to the provided content, 'Class methods include the keyword static in the header before the method name.' The other keywords have different purposes.
A) Class methods can only be called from within their own class.
B) Class methods are associated with the class itself, not with any specific instance of the class.
C) Class methods must always return a value.
D) Class methods cannot have any parameters.
Correct Answer: B
The content explicitly states, 'Class methods are associated with the class, not instances of the class.' This is their defining feature.
A) Converter.inchesToCm()
B) new Converter.inchesToCm()
C) inchesToCm(Converter)
D) A new instance of Converter must be created before calling the method.
Correct Answer: A
The provided text states, 'Class methods are typically called using the class name along with the dot operator.' Therefore, `Converter.inchesToCm()` is the correct syntax.
A) Only Call 1 is valid.
B) Only Call 2 is valid.
C) Both Call 1 and Call 2 are valid ways to call the class method from within its defining class.
D) Neither call is valid because a class method cannot be called from an instance method.
Correct Answer: C
The content states, 'When the method call occurs in the defining class, the use of the class name is optional in the call.' Therefore, both calling with the class name (`MyRobot.getRobotCount()`) and without it (`getRobotCount()`) are valid.
A) Welcome
B) == Welcome ==
C) TextUtils.Welcome
D) The code will produce a compilation error.
Correct Answer: B
The code calls the `static` class method `createHeader` on the `TextUtils` class, passing "Welcome" as the argument. The method concatenates this string with "== " and " ==", resulting in the output "== Welcome ==".
A) 15
B) 20
C) 30
D) The code will not compile because `add` is a private method.
Correct Answer: C
The call `Calculator.compute(5)` executes the `compute` method. Inside `compute`, the class method `add` is called with arguments 5 and 10, which returns 15. This result (15) is then multiplied by 2, returning a final value of 30. The call to `add` is valid because it occurs within the defining class.
A) The instance `myConfig` only.
B) Any instance of the `Config` class.
C) The `Config` class itself.
D) The constructor of the `Config` class.
Correct Answer: C
Because `getVersion` is a `static` method, it is a class method. The provided content states that 'Class methods are associated with the class, not instances of the class.' Therefore, the method is associated with the `Config` class, not the `myConfig` instance.
A) This is a class method because it is public.
B) This is a class method and can be called using `Validator.isLengthValid(...)`.
C) This is not a class method because it is missing the `static` keyword.
D) This is not a class method because it returns a `boolean`.
Correct Answer: C
The content specifies that 'Class methods include the keyword static in the header'. Since this method header does not contain the `static` keyword, it is an instance method, not a class method. Therefore, it cannot be called using the class name.
A) The code compiles and prints `<alert>`.
B) The code compiles but results in a runtime error.
C) The code fails to compile because `format` is not a class method.
D) The code fails to compile because `main` cannot call methods from other classes.
Correct Answer: C
The method `format` in the `Message` class is missing the `static` keyword, so it is an instance method, not a class method. The code attempts to call it using the class name (`Message.format`), which is the syntax for calling a class method. This mismatch will cause a compilation error.