AP CS A Unit 1 Review

AP CS A Unit 1 Review

Assessment

Quiz

Computers

9th - 12th Grade

Practice Problem

Medium

Created by

Danielle Mills

Used 270+ times

FREE Resource

About this resource

This quiz covers the fundamental concepts of AP Computer Science A Unit 1, focusing on Java programming basics and foundational computer science principles. Students need a solid understanding of Java syntax including print statements, variable declarations, data types, and type casting to solve the output prediction problems. They must grasp integer division versus floating-point division, understand how arithmetic operations work with different data types, and recognize the difference between `print` and `println` methods. The quiz also requires knowledge of identifier naming rules, Java commenting syntax, and arithmetic operators including the modulus operator. Students need to understand core computer science concepts such as abstraction, modular programming, algorithms, and the distinction between high-level and low-level programming languages. This material is appropriate for grades 11-12, as it aligns with the AP Computer Science A curriculum that covers object-oriented programming concepts and requires mathematical reasoning skills typically developed in high school. Created by Danielle Mills, a Computers teacher in US who teaches grade 9-12. This comprehensive review quiz serves multiple instructional purposes in the AP Computer Science A classroom, functioning effectively as a formative assessment tool to gauge student understanding before moving to more complex programming concepts. Teachers can deploy this quiz as a warm-up activity at the beginning of class to activate prior knowledge, assign it as homework to reinforce daily lessons, or use it as a review session before unit exams. The mix of multiple-choice questions, fill-in-the-blank problems, and code analysis makes it ideal for identifying specific areas where students need additional support, particularly in understanding Java syntax rules and fundamental programming concepts. This quiz aligns with College Board AP Computer Science A standards, specifically covering primitive types, using objects, and program design and algorithm development from the AP CSA framework.

See more

Student preview

quiz-placeholder

40 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Consider the following code segment.


System.out.println("W");

System.out.println("X");

System.out.print("Y");

System.out.print("Z");


What is printed as a result of executing the code segment?

WXYZ

W

XYZ

WX

YZ

W

X

YZ

W

X

Y

Z

2.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Consider the following code segment.

int x = 10;

int y = 20;

/* missing code */

System.out.print(top / bottom);

Which of the following replacements for /* missing code */ will cause an ArithmeticException to occur?

I. int top = x - y;

int bottom = y - x;

II.int top = 2 * x;

int bottom = y - top;

III. int top = x + y;

int bottom = 2 * top;

I. only

II. only

III. only

I. and II.

II. and III.

3.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

A store sells rope only in whole-foot increments. Given three lengths of rope, in feet, the following code segment is intended to display the minimum length of rope, in feet, that must be purchased so that the rope is long enough to be cut into the three lengths. For example, for lengths of 2.8 feet, 3 feet, and 5 feet, the minimum length of rope that must be purchased is 11 feet. For these inputs, the code segment should display 11. As another example, for lengths of 1.1 feet, 3.2 feet, and 2 feet, the minimum length of rope that must be purchased is 7 feet. For these inputs, the code segment should display 7.


double len1;

double len2;

double len3;

double total = len1 + len2 + len3;

int minLength = (int) (total + 0.5);

System.out.print(minLength);


Which of the following best describes the behavior of the code segment?

The code segment works as intended for all nonnegative values of len1, len2, and len3.

The code segment works as intended but only when the sum of the three lengths is an integer or the decimal part of the sum of the three lengths is greater than or equal to 0.5.

The code segment does not work as intended for some values of len1, len2, and len3. It could be corrected by casting len1, len2, and len3 to int before adding them together and assigning the sum to minLength.

The code segment does not work as intended for some values of len1, len2, and len3. It could be corrected by declaring minLength as a double and casting it to an int in the System.out.print statement.

The code segment does not work as intended for any values of len1, len2, and len3. It returns the sum of 0.5 and the three lengths for all values of len1, len2, and len3.

4.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Consider the following code segment, which is intended to display 6.0.


double fact1 = 1 / 2;

double fact2 = 3 * 4;

double product = fact1 * fact2;

System.out.println(product);


Which of the following best describes the error, if any, in the code segment?

There are no errors and the code works as intended.

Either the numerator or the denominator of the fraction 1 / 2 should be cast as double.

The expression fact1 * fact 2 should be cast as double.

The expressions 1 / 2 and 3 * 4 should both be cast as double.

The variables fact1 and fact2 should both be declared as int.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Is the following identifier legal or illegal?

MyFirstProgram

legal

illegal

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Is the following identifier legal or illegal

Hello+there

legal

illegal

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Is the following identifier legal or illegal

void

legal

illegal

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?