Back to Challenge Set 15

Question Set 9

Difficulty  

divider

What This Is

Six exam-style questions, mostly about methods and return values — Activities 2.1 to 2.3. These sets are cumulative, so Quarter 1 is still fair game. This is the first set of Quarter 2.

Two pairs this time. Questions 1 and 2 differ by one word; Questions 3 and 4 are the same procedure in the two notations, with two different answers. Read each pair side by side when you check your work.

How to Do This One

  • Set a timer for 10 minutes before you start.
  • When the timer ends, stop. Mark anything unfinished as unfinished — that is real information, not a failure.
  • Work them out. Do not run the code. On exam day there is no computer.
  • For each question, also write sure or unsure. This is graded on completion, so an honest unsure costs you nothing and tells us both where to look.

Guessing beats leaving it blank. There is no penalty for a wrong answer on the AP exam, so a blank is a guaranteed zero where a guess is not.


The Questions

Four have exactly one correct answer, one asks you to select all that apply, and the last is about data or the impact of computing rather than about code.


Question 1

What does the following C# display?

Question 1
Console.WriteLine(Shout("go"));
string Shout(string word)
{
return $"{word}!";
}
  1. go
  2. go!
  3. Nothing — Shout does not print anything
  4. Nothing — the program will not build

Question 2

The same program, with Shout changed to print instead of return. What happens?

Question 2
string x = Shout("go");
Console.WriteLine(x);
void Shout(string word)
{
Console.WriteLine($"{word}!");
}
  1. go! is displayed twice
  2. go! is displayed once, then a blank line
  3. go! is displayed once
  4. Nothing — the program will not build

Question 3

What does the following C# display?

Question 3
Console.WriteLine(Half(9));
Console.WriteLine(Half(Half(40)));
int Half(int n)
{
return n / 2;
}
  1. 4.5, then 10
  2. 4, then 10
  3. 4, then 20
  4. 4.5, then 20

Question 4

The following is written in AP exam notation. What does it display?

Question 4
PROCEDURE half(n)
{
RETURN(n / 2)
}
DISPLAY(half(9))
DISPLAY(half(half(40)))
  1. 4.5 10
  2. 4 10
  3. 4.5 20
  4. 4 20

Question 5 — Select all that apply

Which of these are true of return in C#?

  1. It hands a value back to the line that called the method
  2. It ends the method immediately
  3. A line written after it, in the same block, still runs
  4. A method declared double that never reaches a return will not build
  5. It displays the value on the screen

Question 6 — Data and Impact

A school moves all its homework to an online system that needs a fast internet connection at home. Students in one rural area, where home internet is slow or unavailable, start falling behind. This is an example of:

  • (A) Crowdsourcing
  • (B) The digital divide
  • (C) Lossy compression
  • (D) Metadata

Submit

  • Your answer to each question, with sure or unsure
  • Whether you finished inside 10 minutes, and if not, how far you got
  • One sentence: which question took you longest, and what slowed you down?

This is graded on completion, not accuracy. A thoughtful wrong answer earns the same as a right one. What is being built here is speed and stamina, and both require being allowed to get things wrong cheaply.

Start the Timer