AP® Computer Science A Using Objects and Methods Multiple Choice Questions
Work through AP Computer Science A multiple-choice questions on Using Objects and Methods, 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
Using Objects
Question 462
Multiple choice
Primitive Types
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
Using Objects
Question 464
Multiple choice
Primitive Types
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
Using Objects
Question 466
Multiple choice
Using Objects
Question 467
Multiple choice
Primitive Types
Question 468
Multiple choice
Using Objects
Question 469
Multiple choice
Using Objects
Question 461 of 681
Page 47 of 69
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.

