FRQ workshop: the 4 question types
自由作答部分
- AP CSA 考试包含选择题和 自由回答题 部分。在当前格式下,您需在 Bluebook 应用程序中输入这两种类型的作答;自由回答题要求编写 Java 代码。
- 当前自由回答题部分共有 4 道题目(FRQs)。以下四个重点内容描述了当前考试格式;请查阅 官方考试页面 以获取您报考年份的具体信息。
- 这一课是这 4 种类型的快速地图。了解套路会让考试不再可怕。你能做到的!
类型 1:方法与控制结构
- 第 1 题目前要求在一个给定的类中编写 两个方法,或一个构造方法和一个方法。A 部分涉及迭代、选择或两者结合,并调用方法;B 部分则调用
String方法。 - 外围类已提供。请遵循每个要求的方法或构造方法的声明及其规格说明。
- 下方的简短计数示例旨在练习一项实用技能;它 并非当前完整的第 1 题。同时请练习构造方法、方法调用及
String操作。
public class Grades {
// Count the scores that are 60 or more.
public static int countPassing(int[] scores) {
int count = 0;
for (int s : scores) {
if (s >= 60) {
count = count + 1;
}
}
return count;
}
public static void main(String[] args) {
int[] scores = {72, 40, 95, 60, 33};
System.out.println(countPassing(scores)); // 3
}
}
类型 2:类的设计
- 题目给你一段类的描述,你必须写出整个类。
- 也就是说:实例变量、一个构造方法(constructor),以及他们要求的那些方法。
- 记住用
private字段、构造方法要和类同名、以及this.field = field。第 6 课覆盖了这些。
public class Student {
private String name;
private int score;
public Student(String name, int score) {
this.name = name;
this.score = score;
}
public int getScore() {
return score;
}
}
类型 3:基于 ArrayList 的数据分析
- 第 3 题目前要求您编写一个方法,用于在
ArrayList中使用、分析和处理数据。数组遍历是有益的准备工作,但当前的重点是ArrayList。 - 常见任务:找一个值、数个数、删除元素,或者建一个新列表。
- 在循环里删除元素时要小心下标。第 9–11 课覆盖了这些。
// Count the Strings longer than 3 letters.
int count = 0;
for (int i = 0; i < words.size(); i++) {
if (words.get(i).length() > 3) {
count++;
}
}
return count;
类型 4:2-D 数组
- 您需要处理一个 2-D 数组(即由行和列组成的网格)。
- 你要用嵌套循环:外层循环走行,内层循环走列。
- 常见任务:对一行求和、对一列求和、找最大值,或者数匹配的个数。第 12 课覆盖了这些。
// Add up every value in the grid.
int total = 0;
for (int r = 0; r < grid.length; r++) {
for (int c = 0; c < grid[r].length; c++) {
total += grid[r][c];
}
}
return total;
考试策略:仔细读题
- 先把整道题读完。 划出方法必须返回什么,以及它的参数是什么。
- 看他们给的例子表格。它准确地告诉你代码应该产生什么结果。
- 抄下他们给你的方法头(method header)。不要改它的名字、参数或返回类型。
考试策略:写出能用的方法
- 先写出循环的框架,再填里面的内容。在脑子里一步一步把它跑通。
- 正确地遍历:下标从
0开始,在length(或size())处停止;检查两端的边界。 - 用
return返回正确的类型。如果方法头写的是int,就返回一个int。
考试策略:小分也能累积
- 即使整个方法不完美,能用的部分也会得分。一定要写出一些东西。
- 只用这门课里你学过的 Java。简单、正确的代码胜过花哨的代码。
- 继续下一题之前,用题目里的例子数值检查一下你的答案。
你准备好了
- 当前的重点内容包括 方法与控制、类设计、ArrayList 数据分析 以及 2-D 数组。考试格式可能会发生变化;请使用官方网站查询您参加考试的年份信息。
- 利用之前的课程复习相关操作,然后练习完整的官方发布试题,并将其与官方评分标准进行对比。此处任务侧重于专项练习,而非官方 AP 试题或对您 AP 成绩的预测。
- 保持冷静,仔细读题,写出你会的代码。祝你考试顺利!
常见错误
- 方法头要完全对上:返回类型和参数。
- 开始写之前先读完整个题目。
现在轮到你
- 尝试自己完成一道 FRQ 风格的方法题——其结构与上述类型 1 相同。
- 按检查答案在服务器上编译并运行它。
难度 5/5 · 今日首次完成可获 400 金币及少量额外奖励
FRQ practice — Type 1 (Methods). Complete countAtLeast(int[] scores, int limit) so it returns how many values in scores are at least limit (greater than or equal). Use a loop and an if, like the worked example above.
点击“运行”查看此处输出。
难度 5/5 · 今日首次完成可获 400 金币及少量额外奖励
FRQ practice — Type 2 (Class design). Complete the Rectangle class: store width and height from the constructor, and finish area() so it returns width × height. This practises constructor and method implementation; a complete official question can include more requirements.
点击“运行”查看此处输出。
难度 5/5 · 今日首次完成可获 400 金币及少量额外奖励
Complete countLong(ArrayList<String> words, int limit) to count strings whose length is strictly greater than limit. The list and its strings are non-null; an empty list returns 0. This is focused ArrayList practice, not a complete official FRQ.
点击“运行”查看此处输出。
难度 5/5 · 今日首次完成可获 400 金币及少量额外奖励
Complete countNegative(int[][] grid) to count values less than 0 across all rows. Rows are non-null but may have different lengths or be empty; the grid itself may have no rows. Do not change the grid.
点击“运行”查看此处输出。