zuai-logo
zuai-logo
  1. AP Computer Science A
FlashcardFlashcardStudy GuideStudy GuideQuestion BankQuestion Bank
GlossaryGlossary

Using Objects in AP Computer Science A

Question 1
college-boardComputer Science AAPExam Style
1 mark

When would it be most appropriate to use the Math.abs(a - b) method instead of just computing a - b directly in your code?

Question 2
college-boardComputer Science AAPExam Style
1 mark

Which method from the Java's built-in 'Math' class can generate random numbers between [0 and 1)?

Question 3
college-boardComputer Science AAPExam Style
1 mark

If an algorithm requires the calculation of the square root of a number, which method from the Math class in Java should be used?

Question 4
college-boardComputer Science AAPExam Style
1 mark

What is the return type of the Math.pow() method?

Question 5
college-boardComputer Science AAPExam Style
1 mark

Given an ArrayList nums, which snippet efficiently checks if it is empty before trying to access its first element?

Question 6
college-boardComputer Science AAPExam Style
1 mark

What would be returned by calling Math.sqrt(-4)?

Question 7
college-boardComputer Science AAPExam Style
1 mark

Which following expression could represent the sum of a geometric series where the first term, a, is a power of two, the common ratio r is half, and n equals the number of terms (given n > 0 and always an integer)?

Feedback stars icon

How are we doing?

Give us your feedback and let us know how we can improve

Question 8
college-boardComputer Science AAPExam Style
1 mark

Which Java method returns the absolute value of an int variable named 'x'?

Question 9
college-boardComputer Science AAPExam Style
1 mark

Which expression correctly computes the value of a double x raised to the power of another double y, ensuring that the result is also a positive integer?

Question 10
college-boardComputer Science AAPExam Style
1 mark

Given a recursive method public static int mystery(int x) that uses Math.random() to sometimes increase and other times decrease the value of x before the next recursive call, which change would most likely make it terminate more often?