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

Primitive Types

Question 1
college-boardComputer Science AAPExam Style
1 mark

What unexpected behavior could result from accidentally using assignment '=' instead of equality '==' in an 'if' statement's conditional expression?

Question 2
college-boardComputer Science AAPExam Style
1 mark

Evaluate the expression 'int y = 10 % 4'.

Question 3
college-boardComputer Science AAPExam Style
1 mark

What does the 'x % y' return?

Question 4
college-boardComputer Science AAPExam Style
1 mark

Given that 'a', 'b', and 'c' are all variables of type int initialized to some values, which statement correctly stores into variable 'result' one half of the sum of squares of 'a' and 'b'?

Question 5
college-boardComputer Science AAPExam Style
1 mark

If we want to insert a new value into a sorted array while maintaining its order, what typical algorithm must be used?

Question 6
college-boardComputer Science AAPExam Style
1 mark

Which algorithmic approach would likely be most efficient for finding an item in a balanced binary search tree?

Question 7
college-boardComputer Science AAPExam Style
1 mark

What will be the output of the following code if the integer value 0 is passed to it?

java
try {
    System.out.println(10 / a);
} catch (ArithmeticException e) {
    System.out.println("Error");
}
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

In Java, what is the effect of following code segment on variables a and b? a = 10; b = a++; a = --b;

Question 9
college-boardComputer Science AAPExam Style
1 mark

When refactoring code, what is a primary reason for moving a block of code into its own method?

Question 10
college-boardComputer Science AAPExam Style
1 mark

Which for-loop declaration correctly traverses an integer array named 'numbers' from its end to its beginning?