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.

Subtopic: Using Objects Clear filter

Questions 11–20 of 92
  1. 11
  2. 12
  3. 13
  4. 14
  5. 15
  6. 16
  7. 17
  8. 18
  9. 19
  10. 20

Question 11

Free response Using Objects
Given a string, return a "rotated left 2" version where the first 2 chars are moved to the end. The string length will be at least 2.…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 12

Free response Using Objects
Given a string, return a "rotated right 2" version where the last 2 chars are moved to the start. The string length will be at least 2.…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 13

Free response Using Objects
Given a string, return a string length 1 from its front, unless front is false, in which case return a string length 1 from its back. The string will be…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 14

Free response Using Objects
Given a string, return a version without both the first and last char of the string. The string may be any length, including 0.…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 15

Free response Using Objects
Given a string of even length, return a string made of the middle two chars, so the string "string" yields "ri". The string length will be at least 2.…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 16

Free response Using Objects
Given a string, return true if it ends in "ly". endsLy("oddly") → true endsLy("y") → false…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 17

Free response Using Objects
Given a string and an int n, return a string made of the first and last n chars from the string. The string length will be at least n. nTwice("Hello",…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 18

Free response Using Objects
Given a string and an index, return a string length 2 starting at the given index. If the index is too big or too small to define a string length 2, use the…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 19

Free response Using Objects
Given a string of odd length, return the string length 3 from its middle, so "Candy" yields "and". The string length will be at…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 20

Free response Using Objects
Given a string, return true if "bad" appears starting at index 0 or 1 in the string, such as with "badxxx" or "xbadxx" but not "xxbadxx". The string may be any…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 11 of 92
Page 2 of 10