Verityprep
Question Bank

AP® Computer Science A FRQ Practice: Free-Response Questions with Solutions

Work through AP Computer Science A free-response questions unit by unit, 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 301–310 of 329
  1. 301
  2. 302
  3. 303
  4. 304
  5. 305
  6. 306
  7. 307
  8. 308
  9. 309
  10. 310

Question 301

Free response Unit 4: Data Collections
A classroom seating arrangement is stored in a class SeatingChart, which uses a two-dimensional String array to hold the name of the student assigned to each…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 302

Free response Unit 4: Data Collections

Information about applicants for a scholarship program is stored in Applicant objects.

public class Applicant
{
    private String name;
    private int score;
    private boolean complete;

    public Applicant(String n, int s, boolean c)
    {
        name = n;
        score = s;
        complete = c;
    }

    public String getName()
    {
        return name;
    }

    public int getScore()
    {
        return score;
    }

    public boolean isComplete()
    {
        return complete;
    }
}

The ScholarshipGroup class stores a list of applicants.

public class ScholarshipGroup
{
    private ArrayList<Applicant> applicants;

    public ScholarshipGroup(ArrayList<Applicant> list)
    {
        applicants = list;
    }

    public ArrayList<String> finalists(int minScore)
    { /* to be written */ }
}

Write the method finalists, which returns a new ArrayList<String> containing the names of all applicants who satisfy both of the following conditions.

  • The applicant's form is complete.
  • The applicant's score is at least minScore.

Among the applicants who satisfy those conditions, only applicants whose score is equal to the highest qualifying score should appear in the returned list. Names in the returned list must appear in the same order as the corresponding applicants appear in applicants. If no applicant qualifies, the method returns an empty list.

For example, if the qualifying applicants have scores 81, 94, 94, 88, the returned list should contain the names of the two applicants whose score is 94, in their original order.

The answer and the full solution open in a window.

Question 303

Free response Unit 4: Data Collections
The TerrainMap class stores a rectangular grid of elevation values in meters. public class TerrainMap { private int[][] height; public TerrainMap(int[][] h) {…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 304

Free response Unit 4: Data Collections
Information about players in a school league is stored in Player objects. public class Player { private String name; private int points; private boolean active;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 305

Free response Unit 4: Data Collections
The DeliveryWindow class stores the number of packages delivered during each recorded hour of a day. public class DeliveryWindow { private int[] packages;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 306

Free response Unit 4: Data Collections

A school system models course requests using the CourseRequest class. A request has a course name, a priority value, and a flag indicating whether the request has already been fulfilled.

public class CourseRequest
{
    private String courseName;
    private int priority;
    private boolean fulfilled;

    public CourseRequest(String name, int p, boolean done)
    {
        courseName = name;
        priority = p;
        fulfilled = done;
    }

    public String getCourseName()
    {
        return courseName;
    }

    public int getPriority()
    {
        return priority;
    }

    public boolean isFulfilled()
    {
        return fulfilled;
    }
}

public class CourseQueue
{
    private ArrayList<CourseRequest> requests;

    public CourseQueue(ArrayList<CourseRequest> data)
    {
        requests = data;
    }

    public ArrayList<String> topOpenRequests(int minPriority)
    { /* to be written */ }
}

Write the method topOpenRequests, which returns a new ArrayList<String> containing the names of all unfulfilled requests whose priority is at least minPriority and is equal to the highest priority among all such requests. Names must appear in the same order as the corresponding requests appear in requests. If no request qualifies, the method returns an empty list.

The answer and the full solution open in a window.

Question 307

Free response Unit 4: Data Collections
An OrchardGrid object stores fruit counts for trees arranged in a rectangular grid. Each entry in fruit is the number of fruits currently on one tree. public…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 308

Free response Unit 4: Data Collections
This question involves the analysis of messages exchanged in a chat room. The following Message class represents a single message in the chat room. public class…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 309

Free response Unit 4: Data Collections
This question involves analyzing an orchard of apples to determine how many apple pies can be baked. The orchard is represented as a two-dimensional array of…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 310

Free response Unit 4: Data Collections
Temperature Range Set directions Only what was taught. Arrays (create, read, write, length, traverse), for-each, swap and reverse, max/min, String methods…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 301 of 329
Page 31 of 33