Welcome to
Unit 2 AP Computer Science A Multiple Choice Questions! Grab some paper and a pencil π to record your answers as you go. You can see how you did on the
Unit 2 Practice Questions Answers and Review sheet once you're done. Don't worry, we have tons of resources available if you get stumped π on a question. And if solo study is not your thing, join a group in
Hours!
Not ready to take a quiz yet?
Start studying unit 2 here: Intro to Unit 2This content, covered in key topic 2.6, reviews what each escape character prints.Β
Facts about the test: The AP Computer Science A exam has 40 multiple choice questions and you will be given 90 minutes to complete the section. That means it should take you around 34 minutes to complete 15 questions.
*The following questions were not written by CollegeBoard and although they cover information outlined in the AP Computer Science A Course and Exam Description the formatting on the exam may be different.
1. Which of the following would evaluate to the number 1?
A. x / y
B. y / x
C. a % b
D. (a + x) / x
2. Consider String a below. Which of the following would create a new String with the value, "ram"? String a = new String ("Java Program");
A. String b=string (a)
B. String b = a.substring(9);
C. String b= a.substring (a)
D. String b = a.substring (12)
3.Β What special type of data is identified by the fact that it has methods, unlike primitive data?
A. objects
B. methods
C. variables
D. constants
4. Consider the code segment attached. What is the result displayed?
A. 3
B. 5
C. 8
D. 125
5. What is the value of z stored after the following code is run?
A. 6
B. 6.0
C. 6.00
D. 6.00001
6. The output of the program code below will not always be the same. What is the range of numbers that could be printed?
A. 0-4
B. 0-6
C. 1-5
D. 1-6
7. Which of the following is the correct import necessary to create a Scanner?
A. create.Scanner;
B. import Java-scanner;
C. import.Scanner;
D. import.util.java.Scanner;
8. What will be the result of 2 % 6?
A. 0
B. 2
C. 3
D. 4
9. Which of the following would be the most appropriate variable to store a bank account balance?
A. double bankBalance;
B. decimal money;
C. int balance;
D. long money;
10. Which operator is known as the assignment statement?
A. =
B. ==
C. -->
D. <--
11. What is the disadvantage of the import statement: import java.util.*; ?
A. there is no disadvantage
B. the file would import all code in java.util, which would make the file bigger
C. it would only import the code that has * with it
D. this doesn't exist, so it would give an error
12. Which of the following is overloading?
A. When one constructor is defined in a class
B. When a constructor takes more than one parameter
C. When a constructor takes one parameter
D. When more than one constructor is defined in a class
13. Which of the following is valid syntax for creating and initializing a World object?
A. World w = null;
B. World w = new.World;
C. World w = new.World();
D. World w = World();
14. Which of the following is the correct signature for a no-argument constructor?
A. public World()
B. public World
C. public World(int width)
D. public World(int width, int height)
15. In new World (150, 200), what are 150 and 200?
A. formal parameters
B. actual parameters
C. objects
D. classes
π€Connect with other students studying AP Computer Science A with
Hours