This content, covered in key topic 2.6, reviews what each escape character prints.
β
STOP!β Before you look at the answers make sure you gave this practice quiz a try so you can assess your understanding of the concepts covered in unit 2. Click here for the practice questions:
AP Computer Science A Unit 2 Multiple Choice Questions.
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
Answer: % is remainder, which will be an integer value when a and b are divided
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)
Answer: This creates a substring of the original string a, starting at the 9th character
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
Answer: Another giveaway that this is not primitive data is that variables of this type begin with a capital letter.
π Study AP Computer Science A, Unit 2.0: Unit 2 Overview
4. Consider the code segment attached. What is the result displayed?
A. 3
B. 5
C. 8
D. 125
Answer: Will result in the location of "t", which is 5
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
Answer: Double will include one decimal place, even when the value is exact
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
Answer: Random will give between 0-1, the word length will be 4.
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;
Answer: Import from the utility library
8. What will be the result of 2 % 6?
A. 0
B. 2
C. 3
D. 4
Answer: Remainder when 2 is divided by 6.
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;
Answer: Double will give decimal for cents
π Study AP Computer Science A, Unit 2.9: Using the Math Class
10. Which operator is known as the assignment statement?
A. =
B. ==
C. -->
D. <--
Answer: The assignment operator is the equal sign
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
Answer: This is just the definition of overloading.
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();
Answer: w defined as new, and object of 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)
Answer: () must be included but empty
15. In new World (150, 200), what are 150 and 200?
A. formal parameters
B. actual parameters
C. objects
D. classes
Answer: An actual parameter (argument) is the value passed into the constructor.
π Study AP Computer Science A, Unit 2.4: Calling a Void Method With Parameters
What can we help you do now?
π¦Jump to AP Computer Science A Unit 3 Multiple Choice Questions π€Connect with other students studying AP Computer Science A with Hours