AP CSP 3.4 Exercise 2: Strings Applied Challenge

Big Idea 3: Algorithms and Programming · Topic 3.4 · Exercise 2

Strings: Applied Challenge

Six questions on building, joining, and reading strings, including where a number stops being a number.

How this one is different

The trap in every one of these is the moment a value crosses between number and text. Watch for it.

Applied Practice

6 questions · scenario driven · every answer is recorded for your teacher

Question 1 of 6Trace
If first holds "Ada" and last holds "Lovelace", what does concatenating first, a space, and last produce?
Incorrect. No comma appears among the pieces being joined.
Incorrect. This omits the space that was explicitly included.
Correct. Concatenation joins the pieces in the order given, producing the two names separated by the space.
Incorrect. The order given puts first before last.
Question 2 of 6Analyze
A program joins the text "5" and the text "3".
What is the result, and why is it not 8?
Incorrect. The values are text. Their appearance as digits does not make them numbers.
Correct. Concatenation places one sequence of characters after another, so two single character strings become a two character string.
Incorrect. Nothing about concatenation multiplies.
Incorrect. Joining text is the ordinary operation on strings.
Question 3 of 6Apply
A username must be built from a first name, an underscore, and a graduation year. Which order of operations produces alex_2028 from "alex" and 2028?
Correct. Concatenation needs text on both sides, so the numeric year is converted first and then joined.
Incorrect. Converting the finished username to a number destroys it, since it contains letters.
Incorrect. A substring of the year would drop digits that the username needs.
Incorrect. Adding a number to a name is not a defined operation and would not produce text.
Question 4 of 6Trace
The string word holds "COMPUTER". What is its length, and what is the substring of 4 characters starting at position 1?
Incorrect. Counting seven drops a letter.
Incorrect. OMPU starts at position 2 rather than 1.
Incorrect. TER is the tail of the string and is only three characters.
Correct. C, O, M, P, U, T, E, R is eight characters, and four characters from position 1 is COMP.
Question 5 of 6Transfer
A program must check whether a password is at least 8 characters.
Which check is correct?
Incorrect. Strictly greater than 8 rejects a valid 8 character password.
Incorrect. This accepts only passwords of exactly 8 characters and rejects longer ones.
Correct. At least 8 means 8 or more, which is what the greater than or equal comparison expresses.
Incorrect. Comparing the text itself to a number does not measure its length.
Question 6 of 6Evaluate
A student stores phone numbers as numbers rather than text.
Which consequence is real and specific?
Incorrect. They can be stored either way. The question is which representation preserves the data.
Correct. Numbers carry value, not formatting, so a leading zero has nowhere to live and disappears. That is why identifiers are stored as text.
Incorrect. Storing a value as a number does not sort anything.
Incorrect. Nothing about the choice prevents the program from running.

Where to go next

Get in Touch

Whether you're a student, parent, or teacher — I'd love to hear from you.

Just want free AP CS resources?

Enter your email below and check the subscribe box — no message needed. Students get daily practice questions and study tips. Teachers get curriculum resources and teaching strategies.

Typically responds within 24 hours

Message Sent!

Thanks for reaching out. I'll get back to you within 24 hours.

🏫 Welcome, fellow educator!

I offer curriculum resources, practice materials, and study guides designed for AP CS teachers. Let me know what you're looking for — whether it's classroom materials, a guest speaker, or Teachers Pay Teachers resources.

Email

[email protected]

📚

Courses

AP CSA, CSP, & Cybersecurity

Response Time

Within 24 hours

Prefer email? Reach me directly at [email protected]