FRQ workshop: the 4 question types · เวิร์กช็อป FRQ: ประเภทคำถามทั้ง 4
The free-response section
- The AP CSA exam has two parts. Part 1 is multiple choice. Part 2 is free response (you write Java by hand).
- There are always 4 free-response questions (FRQs), and they come in the same 4 types every year.
- This lesson is a quick map of the 4 types. Knowing the pattern makes the exam much less scary. You can do this!
ส่วนข้อเขียนเปิด (Free-response section)
- การสอบ AP CSA มีสองส่วน ส่วนที่ 1 เป็นข้อสอบตัวเลือก ส่วนที่ 2 คือ ข้อเขียนเปิด (คุณเขียน Java ด้วยมือ)
- จะมีคำถามข้อเขียนเปิด (FRQs) ทั้งหมด 4 ข้อ และมีรูปแบบที่ เหมือนเดิมทั้ง 4 แบบ ทุกปี
- บทเรียนนี้เป็นแผนที่สรุป 4 รูปแบบอย่างรวดเร็ว การรู้รูปแบบจะทำให้การสอบดูน่ากลัวน้อยลง คุณทำได้!
Type 1: Methods and Control Structures
- You write one or two methods using loops,
if, and simple math onint,double,boolean, andString. - No class to design — the class is given. You just fill in the method body.
- This is the most "plain coding" question. Lessons 1–8 cover everything you need.
รูปแบบที่ 1: Methods and Control Structures
- คุณเขียน เมทόδหนึ่งหรือสองเมทόδ โดยใช้ลูป,
if, และคณิตศาสตร์พื้นฐานบนint,double,boolean, และString - ไม่ต้องออกแบบ Class เพราะมี Class มาให้แล้ว คุณเพียงเติมเนื้อหาภายในเมทόδเท่านั้น
- นี่คือคำถามแบบ "เขียนโค้ดตรงๆ" มากที่สุด บทเรียนที่ 1–8 ครอบคลุมทุกสิ่งที่คุณต้องการ
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
}
}
Type 2: Class Design
- You are given a description of a class and must write the whole class.
- That means: instance variables, a constructor, and the methods they ask for.
- Remember
privatefields, the constructor with the same name as the class, andthis.field = field. Lesson 6 covers this.
รูปแบบที่ 2: Class Design
- คุณได้รับ คำอธิบาย ของ Class และต้อง เขียน Class ทั้งชุด
- นั่นหมายถึง: ตัวแปรinstance, Constructor, และเมทόδตามที่โจทย์กำหนด
- จำไว้เรื่อง
privatefields, Constructor ที่มี ชื่อเดียวกับ Class, และ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;
}
}
Type 3: Array / ArrayList
- You work with an
ArrayList(or sometimes an array) and write code that traverses it. - Common jobs: find a value, count items, remove items, or build a new list.
- Watch the index carefully when you remove while looping. Lessons 9–11 cover this.
รูปแบบที่ 3: Array / ArrayList
- คุณทำงานกับ
ArrayList(หรือบางครั้งเป็น Array) และเขียนโค้ดเพื่อ 遍历 (traverse) มัน - งานทั่วไป: หาค่า, นับจำนวน, ลบรายการ, หรือสร้างรายการใหม่
- ระวัง Index อย่างละเอียดเมื่อ ลบ รายการขณะวนลูป บทเรียนที่ 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;
Type 4: 2-D Array
- You work with a 2-D array (a grid of rows and columns).
- You use nested loops: an outer loop for rows, an inner loop for columns.
- Common jobs: sum a row, sum a column, find the largest value, or count matches. Lesson 12 covers this.
รูปแบบที่ 4: 2-D Array
- คุณทำงานกับ 2-D Array (ตารางที่มีแถวและหลัก)
- คุณใช้ ลูปซ้อน: ลูปภายนอกสำหรับแถว, ลูปภายในสำหรับหลัก
- งานทั่วไป: รวมค่าในแถว, รวมค่าในหลัก, หาค่าน้อยสุด/สูงสุด, หรือนับความตรงกัน บทเรียนที่ 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;
Exam strategy: read carefully
- Read the whole question first. Underline what the method must return and what its parameters are.
- Look at the example table they give. It shows exactly what your code should produce.
- Copy the method header they give you. Do not change its name, parameters, or return type.
กลยุทธ์การสอบ: อ่านอย่างละเอียด
- อ่านโจทย์ทั้งหมดก่อน ใต้เส้นขีดเน้นสิ่งที่เมทόδต้อง Return และ Parameters ของมันคืออะไร
- ดู ตารางตัวอย่าง ที่เขาให้มา มันแสดงว่าโค้ดของคุณควรสร้างผลลัพธ์อะไรออกมา
- คัดลอก Method header ที่เขาให้มา อย่าเปลี่ยนชื่อ, Parameters, หรือ Return type ของมัน
Exam strategy: write methods that work
- Write the base of a loop first, then fill in the body. Get it running in your head step by step.
- Traverse correctly: start the index at
0, stop atlength(orsize()); check the edges. - Use
returnwith the right type. If the header saysint, return anint.
กลยุทธ์การสอบ: เขียนเมทόδที่ทำงานได้
- เขียน โครงสร้างพื้นฐานของลูป ก่อน แล้วค่อยเติมเนื้อหาใน Body使其 Run ในหัวทีละขั้นตอน
- 遍历ให้ถูกต้อง: เริ่ม Index ที่
0, หยุดที่length(หรือsize()); ตรวจสอบขอบเขต - ใช้
returnพร้อม Type ที่ถูกต้อง ถ้า Header บอกว่าintให้ return一个int
Exam strategy: small wins add up
- You get points for parts that work, even if the whole method is not perfect. Always write something.
- Use only Java you know from this course. Simple, correct code beats clever code.
- Check your work with the example values from the question before you move on.
กลยุทธ์การสอบ: ผลลัพธ์เล็กๆ บวกกันเป็นใหญ่
- คุณได้คะแนนจาก ส่วน ที่ทำงานได้ แม้เมทόδทั้งหมดจะไม่สมบูรณ์แบบ ต้องเขียน บางสิ่ง เสมอ
- ใช้เฉพาะ Java ที่คุณรู้จากบทเรียนนี้ โค้ดที่เรียบง่ายและถูกต้อง ชนะโค้ดที่ฉลาดแต่ซับซ้อน
- ตรวจสอบงานของคุณด้วยค่าตัวอย่างจากโจทย์ก่อนจะข้ามไปข้อถัดไป
You are ready
- The 4 types never change: methods, class design, array/ArrayList, and 2-D array.
- Every skill you need for these four FRQ types is in lessons 1–12. Practice each type a few times and the pattern becomes familiar.
- Stay calm, read carefully, and write the code you know. Good luck on the exam!
คุณพร้อมแล้ว
- 4 รูปแบบนี้ไม่เปลี่ยนแปลง: Methods, Class Design, Array/ArrayList, และ 2-D Array
- ทักษะทุกอย่างที่คุณต้องการสำหรับ 4 รูปแบบ FRQ นี้ อยู่ในบทเรียนที่ 1–12 ฝึกฝนแต่ละรูปแบบสักสองสามครั้ง และรูปแบบจะคุ้นเคย
- รักษามุมมองให้สงบ อ่านอย่างละเอียด และเขียนโค้ดที่คุณรู้ คุณทำได้ดีในการสอบ!
Common mistakes
- Match the method header exactly: the return type and the parameters.
- Read the whole prompt before you start coding.
ข้อผิดพลาดที่พบบ่อย
- Match the method header exactly: the return type and the parameters.
- Read the whole prompt before you start coding.
Now you try
- Try one FRQ-style method yourself — the same shape as Type 1 above.
- Press Check answer to compile and run it on the server.
ลองดูเลย
- Try one FRQ-style method yourself — the same shape as Type 1 above.
- Press Check answer to compile and run it on the server.
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. · ฝึกฝน FRQ — ประเภทที่ 1 (Methods) เติม countAtLeast(int[] scores, int limit) เพื่อให้กลับจำนวนค่าใน scores ที่ อย่างน้อย limit (มากกว่าหรือเท่ากับ) ใช้ loop และ if เหมือนตัวอย่างที่แสดงข้างต้น
Click Run to see the output here. · คลิก Run เพื่อดูผลลัพธ์ที่นี่
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 is exactly what a Type 2 FRQ asks for. · ฝึกฝน FRQ — ประเภทที่ 2 (Class design) เติมเต็มคลาส Rectangle: เก็บ width และ height จาก constructor และทำให้ area() ทำงานเสร็จเพื่อให้กลับ width × height นี่คือสิ่งที่ข้อสอบ Type 2 FRQ ต้องการเป๊ะๆ
Click Run to see the output here. · คลิก Run เพื่อดูผลลัพธ์ที่นี่