AP Computer Science Principles Practice Quiz: Strings
Written by AP Content Team, Verified for 2026 AP Exams, Last updated: May 2026
Test your understanding with short quizzes. This quiz has 9 questions to check your progress.
Question 1 of 9
All Questions (9)
A) Finding a part of an existing string.
B) Joining two or more strings together end-to-end.
C) Evaluating a mathematical value from a string.
D) Removing characters from a string.
Correct Answer: B
The provided content defines string concatenation as the process that "joins together two or more strings end-to-end to make a new string."
A) Concatenation
B) Expression
C) Substring
D) Manipulation
Correct Answer: C
The provided content explicitly states, "A substring is part of an existing string."
A) HelloWorld
B) WorldHello
C) Hello World
D) Hello
Correct Answer: A
String concatenation joins strings end-to-end. The string "World" is placed immediately after the string "Hello", with no spaces added, resulting in "HelloWorld".
A) cat ion
B) conic
C) nation
D) tent
Correct Answer: C
A substring is a part of an existing string. The sequence of characters "nation" appears contiguously within "concate**nation**". The other options contain characters or sequences not found in the original string.
A) key board ist
B) keyboardist
C) istkeyboard
D) keyist
Correct Answer: B
The expression involves joining three strings end-to-end. "key" is joined with "board" to make "keyboard", which is then joined with "ist" to make the final string "keyboardist".
A) sub marine
B) marinesub
C) submarine
D) sub
Correct Answer: C
The expression joins the value of `prefix` ("sub") with "marine" end-to-end. This manipulation creates the new string "submarine".
A) notebook
B) oteb
C) book
D) e b
Correct Answer: D
Concatenating `s1` ("note") and `s2` ("book") results in the new string `s3` being "notebook". "notebook", "oteb", and "book" are all parts of "notebook" and are therefore substrings. The option "e b" contains a space, which is not present in the final string, so it is not a substring.
A) `result1` is always identical to `result2`.
B) `result1` is a substring of `result2`.
C) `strA` is a substring of `result2`.
D) `result1` is generally different from `result2`.
Correct Answer: D
Concatenation joins strings end-to-end in a specific order. For example, joining "A" and "B" gives "AB", while joining "B" and "A" gives "BA". Since the order matters and the strings are different, the results are generally different.
A) substring
B) Astring
C) sub string
D) A sub
Correct Answer: D
In step 1, `word` becomes "substring". In step 2, `phrase` is created by joining "A " and "substring", resulting in "A substring". "A sub" is a part of this final string ("**A sub**string") and is therefore a valid substring. Option A is also a substring, but this question asks to identify *a* substring, and all options must be evaluated. Option D correctly identifies a part of the final, concatenated string.