
AP Comp Sci - Unit 2 Review (2.1 - 2.7)
Authored by Steven Gall
Computers
12th Grade - Professional Development
Used 35+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
8 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
2 mins • 5 pts
String oldStr = "ABCDEF";
String newStr = oldStr.substring(1, 3) + oldStr.substring(4);
System.out.println(newStr);
What is printed as a result of executing the code segment?
ABCD
BCDE
BCEF
BCDEF
ABCDEF
2.
MULTIPLE CHOICE QUESTION
1 min • 5 pts
Consider the following method.
public double myMethod(int a, boolean b)
{ /* implementation not shown */ }
Which of the following lines of code, if located in a method in the same class as myMethod, will compile without error?
int result = myMethod(2, false);
int result = myMethod(2.5, true);
double result = myMethod(0, false);
double result = myMethod(true, 10);
double result = myMethod(2.5, true);
3.
MULTIPLE CHOICE QUESTION
2 mins • 5 pts
String temp = "comp";
System.out.print(temp.substring(0) + " " +
temp.substring(1) + " " +
temp.substring(2) + " " +
temp.substring(3));
What is printed when the code segment is executed?
comp
c o m p
comp com co c
comp omp mp p
comp comp comp comp
4.
MULTIPLE CHOICE QUESTION
2 mins • 5 pts
String str = "0";
str += str + 0 + 8;
System.out.println(str);
What is printed as a result of executing the code segment?
8
08
008
0008
Nothing is printed, because numerical values cannot be added to a String object.
5.
MULTIPLE CHOICE QUESTION
2 mins • 5 pts
A student has created a Car class. The class contains variables to represent the following.
* A String variable called color to represent the color of the car
* An int variable called year to represent the year the car was made
* A String variable called make to represent the manufacturer of the car
* A String variable called model to represent the model of the car
* The object vehicle will be declared as type Car.
Which of the following descriptions is accurate?
An instance of the vehicle class is Car.
An instance of the Car object is vehicle.
An attribute of the year object is int.
An attribute of the vehicle object is color.
An attribute of the Car instance is vehicle.
6.
MULTIPLE CHOICE QUESTION
3 mins • 5 pts
Consider the following class.
public class WindTurbine
{
private double efficiencyRating;
public WindTurbine()
{
efficiencyRating = 0.0;
}
public WindTurbine(double e)
{
efficiencyRating = e;
}
}
Which of the following code segments, when placed in a method in a class other than WindTurbine, will construct a WindTurbine object wt with an efficiencyRating of 0.25 ?
WindTurbine wt = new WindTurbine(0.25);
WindTurbine wt = 0.25;
WindTurbine wt = new WindTurbine();
wt = 0.25;
WindTurbine wt = new WindTurbine();
wt.efficiencyRating = 0.25;
new WindTurbine wt = 0.25;
7.
MULTIPLE CHOICE QUESTION
3 mins • 5 pts
ExamScore class. (see Google Slide)
4
5
80
84
85
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
10 questions
TIU Quiz-9
Quiz
•
University
11 questions
Renewable Energy
Quiz
•
12th Grade
10 questions
Latihan Soal Monitoring
Quiz
•
12th Grade
10 questions
Python Boolean and If
Quiz
•
9th - 12th Grade
10 questions
Класи початок з pygame
Quiz
•
University
12 questions
Типы данных Python2
Quiz
•
6th Grade - University
10 questions
python-BTxâu
Quiz
•
9th - 12th Grade
13 questions
Architektura i zarządzanie systemem Windows 10
Quiz
•
9th - 12th Grade
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
29 questions
Alg. 1 Section 5.1 Coordinate Plane
Quiz
•
9th Grade
22 questions
fractions
Quiz
•
3rd Grade
11 questions
FOREST Effective communication
Lesson
•
KG
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
Discover more resources for Computers
20 questions
-AR -ER -IR present tense
Quiz
•
10th - 12th Grade
15 questions
LOTE_SPN2 5WEEK3 Day 2 Itinerary
Quiz
•
Professional Development
22 questions
El Imperfecto
Quiz
•
9th - 12th Grade
20 questions
Black History Month Trivia Game #1
Quiz
•
Professional Development
20 questions
SSS/SAS
Quiz
•
9th - 12th Grade
20 questions
verbos reflexivos en español
Quiz
•
9th - 12th Grade
14 questions
Making Inferences From Samples
Quiz
•
7th - 12th Grade
23 questions
CCG - CH8 Polygon angles and area Review
Quiz
•
9th - 12th Grade