Unit 1 AP Computer Science Practice Exam - New
Unit 1 AP Computer Science Practice Exam - New
1) Which of the following data types 5) Which of the following data types
would best represent the number of would best represent the position of a
passengers on an airplane? light switch with “on” and “off” as
its only two states?
(A) Boolean
(B) Double (A) Boolean
(C) Integer (B) Double
(D) String (C) String
(D) Integer
2) Which of the following data types
would NOT be considered a 6) Which of the following are
primitive data type? considered reference data types?
(A) 15 (A) 2
(B) “7+8” (B) 3
(C) 15.0 (C) 3.5
(D) An error will occur (D) 4
NOTE:
This (A) 17.5
question (B) 17
was (C) 18 (A) 12
edited. (D) An error will occur. (B) 8
(C) 10
10) Which of the following is true about (D) An error will occur
arithmetic operations?
13) The +=, -=, *=, /=, and %=
I. An arithmetic operation that uses operators are known as _______
two integer values will evaluate operators.
to an integer value.
II. It is impossible to add 1 to a (A) compound assignment
variable without ever using the (B) covalent assignment
number 1 in a statement. (C) shorthand assignment
III. An arithmetic operation that uses (D) increment assignment
a double value will evaluate to a
double value. 14) The process of converting one data
type to another is ______ a variable.
(A) I only
(B) II only (A) casting
(C) I and II (B) reassigning
(D) I and III (C) initializing
(E) I, II, and III (D) compounding
END OF SECTION I
1) In the space below, create and initialize a variable represented with the name myVar that
stores the number 13. Then, create and initialize a variable represented with the name
myVarTwo that stores the value of myVar times 2.5 to the closest whole integer.
2)
(a) In the space below, create and initialize the following variables and their values.
scoreB 86.4
scoreC 76.0
scoreD 100
(b) Create and initialize two variables named scoreAverage and scoreRange, that
calculate the average and range of the scores, respectively, using the same variables
you created in part (a).
END OF SECTION II