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

Using Objects in AP Computer Science A

Question 1
college-boardComputer Science AAPExam Style
1 mark

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

Question 2
college-boardComputer Science AAPExam Style
1 mark

Which expression would give you a random even integer between 102 and 120 inclusive by using Java's Math.random() method?

Question 3
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?

Question 4
college-boardComputer Science AAPExam Style
1 mark

Which method from the Math class would you use in Java to obtain the larger of two integers – x and y?

Question 5
college-boardComputer Science AAPExam Style
1 mark

If x and y are both positive double values greater than 0 and less than 10, which code snippet will return a double value closest to an integer without ever exceeding it?

Question 6
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 7
college-boardComputer Science AAPExam Style
1 mark

What would be the result of calling Math.ceil on a negative non-integer double value in Java?

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

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 9
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 10
college-boardComputer Science AAPExam Style
1 mark

How would you generate a random integer between 50 and 100 inclusive using Math.random()?