Writing Classes in AP Computer Science A
If a class contains a public void method named 'updateScore', what can be inferred about this method?
It returns an integer value representing a score.
It can be accessed from outside the class and does not return any value.
It cannot change the state of an object because it's void.
It is private and cannot be accessed directly from outside the class.
Which method signature correctly indicates overloading when added to a class containing public void processData(int data)?
public void processData(int number)
public int processData(double dataValue)
private void processData(int numData)
public static void processData(int info)
If you need a method that checks whether its input integer parameter is prime or not, what should be its return type?
double
boolean
void
int
What is the purpose of parameters?
To specify the access level of the method
To define the body of the method
To determine the name of the method
To allow values to be passed into the method
What happens when a primitive value is passed as a parameter to a method in Java?
One cannot pass a primitive value to a method.
The method receives a copy of the value.
The primitive value is turned into an object.
The method receives a copy of the reference to the value.
Which of the following is NOT an access modifier in Java?
private
global
protected
public
If a class has a private instance variable named 'radius', which method signature would be appropriate for setting its value?
public void setRadius(double newRadius)
void updateRadius(double newRadius)
public double getRadius()
private double setRadius(double newRadius)

How are we doing?
Give us your feedback and let us know how we can improve
What alteration can be made so a method designed to find and return only prime numbers from an integer list inadvertently returns all odd numbers instead?
Removing or modifying the check for divisibility by even numbers other than two.
Initialising count variables outside of loops used for counting factors.
Adding break statements inside nested loops used for checking factors.
Increasing efficiency by only checking up to square root of each number.
When writing a method to sort a list of n elements with merge sort algorithm in Java, which represents its best-case time complexity?
O(n log n)
O(n)
O(log n)
O(n^2)
What is meant by parameter passing in context of methods?
Returning multiple values from functions
Modifying variables declared inside another function
Providing input values when calling a function or procedure
Declaring variables within the header of a function