
AP Comp Sci - Unit 2 Review (2.1 - 2.7)

Quiz
•
Computers
•
12th Grade - Professional Development
•
Hard
Steven Gall
Used 33+ times
FREE Resource
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
8.
MULTIPLE CHOICE QUESTION
3 mins • 5 pts
GameClass error (see Google Slide)
IV only
I and III only
I and IV only
II and IV only
II, III, and IV only
Similar Resources on Wayground
12 questions
OS with C programming

Quiz
•
University
12 questions
Інформатика 5 клас Нуш Пайтон 1 п.21-22

Quiz
•
12th Grade
10 questions
Python Jetcode

Quiz
•
Professional Development
10 questions
Pilot Certification Quiz

Quiz
•
10th Grade - University
13 questions
Игры на Python 1 модуль

Quiz
•
Professional Development
11 questions
Learning Variables

Quiz
•
9th - 12th Grade
10 questions
Podstawy Pythona

Quiz
•
9th - 12th Grade
10 questions
File Handling

Quiz
•
12th Grade
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
20 questions
Brand Labels

Quiz
•
5th - 12th Grade
15 questions
Core 4 of Customer Service - Student Edition

Quiz
•
6th - 8th Grade
15 questions
What is Bullying?- Bullying Lesson Series 6-12

Lesson
•
11th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade