Verityprep
Question Bank · Unit 1

AP® Computer Science A Using Objects and Methods FRQ

Work through AP Computer Science A free-response questions on Using Objects and Methods, then check each answer against a worked solution.

Free · no sign-up Open questions need no account. Sign up or log in to open the rest.

Questions 21–30 of 95
  1. 21
  2. 22
  3. 23
  4. 24
  5. 25
  6. 26
  7. 27
  8. 28
  9. 29
  10. 30

Question 21

Free response Using Objects
Given a string, return a string length 2 made of its first 2 chars. If the string length is less than 2, use '@' for…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 22

Free response Using Objects
Given 2 strings, a and b, return a new string made of the first char of a and the last char of b, so "yo" and "java" yields "ya". If either string is length 0,…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 23

Free response Using Objects
Given two strings, append them together (known as "concatenation") and return the result. However, if the concatenation creates a double-char, then omit one of…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 24

Free response Using Objects
Given a string of any length, return a new string where the last 2 chars, if present, are swapped, so "coding" yields "codign".…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 25

Free response Using Objects
Given a string, if the string begins with "red" or "blue" return that color string, otherwise return the empty string. seeColor("redxx")…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 26

Free response Using Objects
Given a string, return true if the first 2 chars in the string also appear at the end of the string, such as with "edited".…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 27

Free response Using Objects
Given two strings, append them together (known as "concatenation") and return the result. However, if the strings are different lengths, omit chars from the…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 28

Free response Using Objects
Given a string, return a new string made of 3 copies of the first 2 chars of the original string. The string may be any length. If there are fewer than 2 chars,…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 29

Free response Using Objects
Given a string, if a length 2 substring appears at both its beginning and end, return a string without the substring at the beginning, so "HelloHe" yields…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 30

Free response Using Objects
Given a string, return a version without the first 2 chars. Except keep the first char if it is 'a' and keep the second char if it is 'b'. The string may be any…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 21 of 95
Page 3 of 10