1|Page
AP Computer Science A Questions and Answers
100% Correct UPDATED!!!
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? -
ANSWER D.
W
X
YZ
Consider the following code segment.
System.out.print("cat ");
System.out.println("dog ");
System.out.println("horse ");
,2|Page
System.out.print("cow ");
What is printed as a result of executing the code segment? -
ANSWER B. cat dog
horse
cow
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? -
ANSWER D. Hello!How
are you?
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.
,3|Page
hello
world
Which of the following changes can be made so that the code
segment produces the intended output? - ANSWER D. Changing
print in line 2 to println
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? - ANSWER A. Changing print to
println in lines 1 and 2
, 4|Page
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); - ANSWER A. I only
Which statement correctly declares a variable that can store a
temperature rounded to the nearest tenth of a degree? -
ANSWER B. double patientTemp;
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.
AP Computer Science A Questions and Answers
100% Correct UPDATED!!!
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? -
ANSWER D.
W
X
YZ
Consider the following code segment.
System.out.print("cat ");
System.out.println("dog ");
System.out.println("horse ");
,2|Page
System.out.print("cow ");
What is printed as a result of executing the code segment? -
ANSWER B. cat dog
horse
cow
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? -
ANSWER D. Hello!How
are you?
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.
,3|Page
hello
world
Which of the following changes can be made so that the code
segment produces the intended output? - ANSWER D. Changing
print in line 2 to println
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? - ANSWER A. Changing print to
println in lines 1 and 2
, 4|Page
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); - ANSWER A. I only
Which statement correctly declares a variable that can store a
temperature rounded to the nearest tenth of a degree? -
ANSWER B. double patientTemp;
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.