slug
unit1test1
type
Post
status
Published
category
8-AP CSA
date
Aug 10, 2026
summary
tags
quiz
password
icon
AP Computer Science A — Unit 1
Multiple-Choice Questions
Using Objects and Methods — 42 Questions
1.1 Algorithms, Programming, and Errors
1. Which of the following best describes an algorithm?
A. A Java source file
B. A sequence of clear, ordered steps used to solve a problem
C. A program that has already been compiled
D. A collection of Java classes
2. Consider the following code.
What is printed?
A.
7B.
15C.
21D.
353. Which of the following is a syntax error?
A.
B.
C.
D.
1.2 Variables and Data Types
4. Which declaration correctly creates a variable that stores the value
3.14?A.
B.
C.
D.
5. Which of the following is a primitive type in Java?
A.
StringB.
StudentC.
doubleD.
Scanner6. Which statement about the following values is correct?
A. Both are boolean values.
B. Both are String values.
C.
true is boolean and "true" is String.D.
true is String and "true" is boolean.1.3 Expressions and Output
7. What is printed by the following code?
A.
B.
C.
D. Nothing is printed.
8. Which statement correctly prints the following text?
A.
B.
C.
D.
9. What is printed?
A.
2B.
3C.
3.4D.
410. What is printed?
A.
2B.
3C.
3.4D.
511. What is the value of the following expression?
A.
2B.
4C.
7D.
1212. What is printed?
A.
2B.
2.0C.
2.5D. The code does not compile.
1.4 Assignment and Initialization
13. What is the value of
x after the following statements execute?A.
8B.
9C.
16D. The code does not compile.
14. Consider the following code.
What happens?
A.
0 is printed.B.
null is printed.C. A compile-time error occurs because the local variable has not been initialized.
D. A
NullPointerException occurs.1.5 Casting and Ranges of Values
15. What is the value of
y?A.
7B.
8C.
7.9D. The code does not compile.
16. What is the result of the following expression?
A.
-4B.
-3C.
3D.
3.9917. What is printed?
A.
2B.
2.0C.
2.5D.
3.018. What is printed?
A.
2.0B.
2.5C.
3.0D. The code does not compile.
19. Consider the following code.
What is the value of
x?A.
2147483648B.
2147483647C.
-2147483648D. A compile-time error occurs.
20. Why might the following expression not produce exactly
0.3?A. Integer overflow
B. Floating-point round-off error
C. Integer division
D. A syntax error
1.6 Compound Assignment Operators
21. What is the final value of
x?A.
12B.
16C.
18D.
2022. Which statement is equivalent to
A.
B.
C.
D.
23. What is printed?
A.
3B.
5C.
7D.
101.7 APIs and Libraries
24. When reading an API, which information is most useful for determining whether a method call is valid?
A. The color of the IDE
B. Parameter types and their order
C. The number of comments in the program
D. The name of the source file
25. A programmer uses
without knowing how
sqrt internally calculates a square root.This is an example of
A. overflow
B. casting
C. abstraction
D. concatenation
1.8 Documentation and Preconditions
26. Suppose a method has the following documentation.
Which statement best describes the precondition?
A. The method always changes
radius to 0.B. The caller is expected to provide a nonnegative value for
radius.C. The method must return a negative number.
D. The compiler automatically checks that
radius >= 0.1.9 Method Signatures
27. Consider the method.
In the method definition,
x isA. an argument
B. a parameter
C. a constructor
D. an object
28. Consider the call
The value
5 isA. a parameter
B. a method signature
C. an argument
D. a return type
29. Which of the following represents the method signature of this method?
A.
double calculateB.
calculate(int, double)C.
public static doubleD.
calculate(x, y, double)30. Which statement about a
void method is correct?A. It must return an
int.B. It does not return a value to the caller.
C. It cannot have parameters.
D. It must be an instance method.
31. Which pair of methods demonstrates method overloading?
A.
B.
C.
D.
1.10 Class Methods
32. Which of the following is a class method call?
A.
B.
C.
D.
1.11 Math Class
33. What is the result of the following expression?
A.
-3.5B.
3C.
3.5D.
4.034. What is the type of the value returned by
A.
intB.
doubleC.
booleanD.
String35. Which range correctly describes the possible values returned by
A. (0.0 < x < 1.0)
B. (0.0 \le x < 1.0)
C. (0.0 < x \le 1.0)
D. (0.0 \le x \le 1.0)
36. Which expression generates an integer from
5 through 12, inclusive?A.
B.
C.
D.
1.12–1.14 Objects, Constructors, and Instance Methods
37. Which statement is correct?
A. An object is a blueprint for a class.
B. A class is an instance of an object.
C. A class is a blueprint, and an object is an instance of that class.
D. Classes and objects are primitive types.
38. What happens when the following code executes?
A.
n becomes 0.B.
n becomes -1.C. A compile-time error occurs.
D. A
NullPointerException occurs at run time.39. Suppose the
Student API contains only the following constructor.Which object creation is valid?
A.
B.
C.
D.
40. Consider the following code.
What is stored in
part?A.
"com"B.
"pute"C.
"puter"D.
"computer"1.15 Strings
41. What is printed by the following code?
A.
HELLOB.
helloC.
HelloD. The code does not compile.
42. Consider the following statements.
Which of the following is true?
A.
B.
C.
D.
- 作者:现代数学启蒙
- 链接:https://www.math1234567.com/article/unit1test1
- 声明:本文采用 CC BY-NC-SA 4.0 许可协议,转载请注明出处。
相关文章


