AP® Computer Science A Multiple Choice Questions
Work through AP Computer Science A multiple-choice questions unit by unit, then check each answer against a worked solution.
Free · no sign-up Open questions need no account. Sign up or log in to open the rest.
Multiple choice
Unit 1: Using Objects and Methods
Question 462
Multiple choice
Unit 1: Using Objects and Methods
What is printed by the following code segment?
String label = "AP";
int n = 3;
System.out.println(label + (n + 2) + n / 2);
Pick an answer, then check it. The solution opens in a window.
ACorrect answer
Main Solution
Answer
Answer: A. The parentheses make n + 2 evaluate first, giving 5. Integer division makes n / 2 equal to 1. The printed string is "AP51".
Answer: Correct: A
A
AP51
B
AP52
C
AP53
D
AP32
Answer images
Question 463
Multiple choice
Unit 1: Using Objects and Methods
Question 464
Multiple choice
Unit 1: Using Objects and Methods
Consider the following code segment.
int x = 17;
double y = x / 5 + x / 5.0;
What value is stored in
y ?
Pick an answer, then check it. The solution opens in a window.
CCorrect answer
Main Solution
Answer
Answer: C. x / 5 is integer division, so it gives 3. But x / 5.0 gives 3.4. Their sum is 6.4.
Answer: Correct: C
A
3.4
B
6.0
C
6.4
D
6.8
Answer images
Question 465
Multiple choice
Unit 1: Using Objects and Methods
Question 466
Multiple choice
Unit 1: Using Objects and Methods
Question 467
Multiple choice
Unit 1: Using Objects and Methods
Question 468
Multiple choice
Unit 1: Using Objects and Methods
Question 469
Multiple choice
Unit 1: Using Objects and Methods
Question 461 of 2,811
Page 47 of 282
AP® and Advanced Placement® are registered trademarks of the College Board, which is not affiliated with, and does not endorse, Verityprep. Names are used for identification purposes only.

