0% found this document useful (0 votes)
712 views7 pages

SG Unit1ProgressCheckMCQPartA 6317244735fe99.631724482522b9.25286153

The document is a scoring guide for the AP Computer Science A Unit 1 Progress Check, containing multiple-choice questions related to Java programming concepts. It includes code segments and asks for outputs, variable declarations, and error handling. Each question provides several answer options to choose from.

Uploaded by

ruotiangroup
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
712 views7 pages

SG Unit1ProgressCheckMCQPartA 6317244735fe99.631724482522b9.25286153

The document is a scoring guide for the AP Computer Science A Unit 1 Progress Check, containing multiple-choice questions related to Java programming concepts. It includes code segments and asks for outputs, variable declarations, and error handling. Each question provides several answer options to choose from.

Uploaded by

ruotiangroup
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

AP COMPUTER SCIENCE A Scoring Guide

Unit 1 Progress Check: MCQ Part A

1. 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?


(A) WXYZ
W
(B) XYZ

WX
(C) YZ

W
(D) X
YZ
W
X
(E) Y
Z

2. Consider the following code segment.

System.out.print("cat ");
System.out.println("dog ");
System.out.println("horse ");
System.out.print("cow ");

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


(A) cat dog horse cow
cat dog
(B) horse
cow
cat dog
(C)
horse cow
cat
(D) dog
horse cow
cat
dog
(E)
horse
cow

AP Computer Science A Page 1 of 7


Scoring Guide

Unit 1 Progress Check: MCQ Part A

3. Consider the following code segment.

System.out.print("Hello!");
System.out.println("How ");
System.out.print("are ");
System.out.print("you?");

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


(A) Hello!Howareyou?
(B) Hello!How are you?
Hello!
(C)
How are you?
Hello!How
(D)
are you?
Hello!
How
(E)
are
you?

4. Consider the following code segment.

System.out.println(hello); // Line 1
System.out.print(world); // Line 2

The code segment is intended to produce the following output but does not work as intended.

hello
world

Which of the following changes can be made so that the code segment produces the intended output?
(A) Inserting System.out.print(); between lines 1 and 2
(B) Inserting System.out.println(); between lines 1 and 2
(C) Changing println in line 1 to print
(D) Changing print in line 2 to println

(E) Enclosing hello in line 1 and world in line 2 in quotation marks

Page 2 of 7 AP Computer Science A


Scoring Guide

Unit 1 Progress Check: MCQ Part A

5. Consider the following code segment.

System.out.print("Ready"); // Line 1
System.out.print("Set"); // Line 2
System.out.print("Go!"); // Line 3

The code segment is intended to produce the following output but may not work as intended.

Ready
Set
Go!

Which change, if any, can be made so that the code segment produces the intended output?
(A) Changing print to println in lines 1 and 2

(B) Changing print to println in line 3


(C) Interchanging lines 1 and 3
Replacing all three lines with the single statement System.out.println("Ready Set
(D)
Go!");
(E) No change is needed; the code segment works correctly as is.

6. Each of the following code segments is intended to print the word Hello. Which of the following code segments
works as intended?

I. System.out.print("Hello");
II. System.out.print(Hello);
III. System.out.print(He);
System.out.print(llo);

(A) I only
(B) II only
(C) III only
(D) I and II
(E) II and III

7. Which statement correctly declares a variable that can store a temperature rounded to the nearest tenth of a degree?
(A) boolean patientTemp;

(B) double patientTemp;

(C) int patientTemp;


(D) patientTemp = 0;
(E) patientTemp = 0.0;

AP Computer Science A Page 3 of 7


Scoring Guide

Unit 1 Progress Check: MCQ Part A

8. A teacher determines student percentages in a course as the points a student earns divided by the total points
available in the grading period. Points are awarded only in whole number increments, but student percentages are to
be stored as decimals.

The following code segment appears in a program used to compute student percentages. Points that a student earns
are stored in pointsEarned, the total points available in the grading period are stored in totalPoints,
and the student percentage is stored in percentage.

int pointsEarned;
/* missing code */

Which of the following is most appropriate to replace /* missing code */ in the program?
int totalPoints;
(A)
int percentage;
double totalPoints;
(B)
int percentage;
int totalPoints;
(C)
double percentage;
int totalPoints;
(D)
boolean percentage;
double totalPoints;
(E)
boolean percentage;

9. Consider the following code segment:

/* data type 1 */ x = 0.5;


/* data type 2 */ y = true;

Which of the following best describes the data types that should be used to replace
/* data type 1 */ and /* data type 2 */ so that the code segment compiles without error?
The variable x should be declared as an int and the variable y should be declared as a
(A)
boolean.
(B) The variable x should be declared as an int and the variable y should be declared as an int.
(C) The variable x should be declared as a double and the variable y should be declared as an int.
The variable x should be declared as a double and the variable y should be declared as a
(D)
boolean.
The variable x should be declared as a boolean and the variable y should be declared as a
(E)
boolean.

Page 4 of 7 AP Computer Science A


Scoring Guide

Unit 1 Progress Check: MCQ Part A

10. Consider the following code segment.

int x;
int y;
x = 3;
y = /* missing expression */;
x = 1 + 2 * y;
System.out.print(x);
System.out.println(y);

Which of the following can be used as a replacement for /* missing expression */ so that the code segment
prints 94 ?
(A) 3
(B) x
(C) x - 1

(D) x + 1

(E) 1 - 2 * x

11. The volume of a cylinder is equal to the height times the area of the circular base. The area of the circular base is
equal to (pi) times the square of the radius.

The code segment below is intended to compute and print the volume of a cylinder with radius r and height h.
Assume that the double variables r, h, and pi have been properly declared and initialized.

/* missing code */
System.out.print(volume);

Which of the following can be used to replace /* missing code */ so that the code segment works as intended?

I. double baseArea = pi * r * r;
double volume = baseArea * h;
II. double volume = pi * r * r;
volume = volume * h;
III. double volume = pi * r * r * h;
(A) I only
(B) III only
(C) I and III only
(D) II and III only
(E) I, II, and III

AP Computer Science A Page 5 of 7


Scoring Guide

Unit 1 Progress Check: MCQ Part A

12. 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;
(A) I only
(B) II only
(C) III only
(D) I and II
(E) II and III

13. Consider the following code segment.

int a = 1;
int b = 2;
int c = 3;
int d = 4;
double x = a + b * c % d;

What is the value of x when the code segment has been executed?
(A) 1.0
(B) 2.5

(C) 3.0

(D) 7.0
(E) 9.0

14. Which of the following arithmetic expressions evaluates to 1 ?

I. 2 / 5 % 3
II. 2 / (5 % 3)
III. 2 / 5 + 1

Page 6 of 7 AP Computer Science A


Scoring Guide

Unit 1 Progress Check: MCQ Part A

(A) I only
(B) II only
(C) I and II only
(D) II and III only
(E) I, II, and III

15. Consider the code segment below.

int x = 10;
int y = 20;
System.out.print(y + x / y);

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


(A) 1
(B) 1.5
(C) 3

(D) 20

(E) 20.5

AP Computer Science A Page 7 of 7

You might also like