0% found this document useful (0 votes)
434 views4 pages

Unit 1 AP Computer Science Practice Exam - New

This document contains a 20 question practice exam on primitive data types for AP Computer Science A. The exam covers topics like data type selection, variable declaration and initialization, arithmetic operations, exceptions, and number base conversion. It contains multiple choice questions to test understanding of concepts like primitive vs reference types, casting, and integer limits.

Uploaded by

Hisham
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
434 views4 pages

Unit 1 AP Computer Science Practice Exam - New

This document contains a 20 question practice exam on primitive data types for AP Computer Science A. The exam covers topics like data type selection, variable declaration and initialization, arithmetic operations, exceptions, and number base conversion. It contains multiple choice questions to test understanding of concepts like primitive vs reference types, casting, and integer limits.

Uploaded by

Hisham
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Unit 1 AP Computer Science A Practice Exam

Primitive Data Types

Section I – Multiple Choice


Optional Time – 25 minutes
20 Questions

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) String I. String


(B) Boolean II. Boolean
(C) Integer III. Integer
(D) Long
(A) I only
3) When a variable is declared ______, (B) II only
its value cannot be changed once it is (C) I and II
initialized. (D) II and III
(E) I, II, and III
(A) constant
(B) final 7) Which of the following data types
(C) static would best represent a student ID
(D) boolean number that may have leading zeroes
that must be included in the value?
4) When a variable is initialized, the
variable is associated with a location (A) Boolean
in a computer’s ______ that is used (B) String
to hold its value. (C) Integer
(D) Double
(A) processor
(B) RAM
(C) graphics card
(D) CPU

This practice test was created by Ajay Gandecha.


This test and I are not affiliated with, or endorsed by, the College Board.
No questions are copied from the College Board and were made on my own for you to prepare.
Good luck!
8) What value is assigned to the 11) What value is assigned to the
variable “a” in the code below? variable “y” in the code below?

(A) 15 (A) 2
(B) “7+8” (B) 3
(C) 15.0 (C) 3.5
(D) An error will occur (D) 4

9) What value is assigned to the 12) What value is assigned to the


variable “w” in the code below? variable “z” in the code below?

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

This practice test was created by Ajay Gandecha.


This test and I are not affiliated with, or endorsed by, the College Board.
No questions are copied from the College Board and were made on my own for you to prepare.
Good luck!
15) Variable x of a double type can be
to the nearest integer using which 18) An attempt to divide an integer by 0
statement? will result in which of the following
exceptions?
(A) (int)x for both positive and
negative values of x. (A) Stack overflow Exception
(B) (int)(x + 0.5) for both (B) Arithmetic Exception
positive and negative values of x. (C) Infinite Loop Exception
(C) (int)(x + 0.5) for (D) Type Exception
positive values of x, and
(int)(x - 0.5) for 19) Which of the following is true about
negative values of x. arithmetic in Java?
(D) (int)(x + 1) for both
positive and negative values of x. I. Arithmetic follows the order of
operations in Java
16) Which of the following represent the II. The division of the integers as
extrema (minima and maxima) of the shown, 5 / 2, will result in the
possible values that can be stored as value of 2 because integer
an integer? division truncates decimal
numbers.
I. Integer.MIN_VALUE; III. An integer overflow occurs in the
following code:
II. Integer.MAX_VALUE;
Integer.MIN_VALUE - 2;
III. 2,147,483,648
(A) I only
(A) I only
(B) II only
(B) II only
(C) I and II
(C) I and II
(D) II and III
(D) II and III
(E) I, II, and III
(E) I, II, and III
20) Convert 3610 to a hexadecimal
17) In random access memory, integers
number (base 16).
are given a maximum storage space
of _______.
(A) 2416
(B) 0010010016
(A) 2 bytes
(C) 2216
(B) 4 bytes
(D) 4416
(C) 8 bytes
(D) 16 bytes

END OF SECTION I

This practice test was created by Ajay Gandecha.


This test and I are not affiliated with, or endorsed by, the College Board.
No questions are copied from the College Board and were made on my own for you to prepare.
Good luck!
Section II – Free Response Section
Optional Time – 15 minutes
2 Questions

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.

Variable Name Value


scoreA 96.5

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

This practice test was created by Ajay Gandecha.


This test and I are not affiliated with, or endorsed by, the College Board.
No questions are copied from the College Board and were made on my own for you to prepare.
Good luck!

You might also like