AP Computer Science A · CED V.1 (Effective Fall 2025) Section II · 25점 만점 · 한국 학생 빈출 감점 표시 · localStorage 자동 저장
| Q | 유형 | 점수 | 권장 시간 | 핵심 포인트 |
|---|---|---|---|---|
| Q1 | Methods and Control Structures | 7 (PartA 4 + PartB 3) | 22-23분 | iterative/conditional + class method 호출 + String 메서드 |
| Q2 | Class Design | 7 | 23-24분 | class header + private instance vars + constructor + 요구된 method |
| Q3 | Data Analysis with ArrayList | 5 | 18-20분 | ArrayList 메서드(get/add/remove/set/size) + traverse |
| Q4 | 2D Array | 6 | 20-22분 | row/col 인덱스 정확 + nested loop + 2D traverse |
The WordList class contains a list of words and provides operations on those words. Part of the class is shown below.
public class WordList {
/** A list of words. */
private ArrayList<String> words;
// constructor and other methods not shown
/** Returns the number of words in the list that have at least minLen letters. */
public int countLongWords(int minLen) { /* to be implemented in part (a) */ }
/** Returns a new String formed by joining the first letter of each word, in order. */
public String firstLetters() { /* to be implemented in part (b) */ }
}
Part (a) (4 points): Write the method countLongWords. The method returns the number of words in words with length greater than or equal to minLen. Use a loop and the String length() method.
Part (b) (3 points): Write the method firstLetters. The method returns a single String formed by concatenating the first character of each word in words, in order. Use the String substring or charAt method. Assume every word has at least 1 character.
아래 textarea에 코드 입력 — 6초 입력 정지 시 localStorage 자동 저장. static 메서드는 본 문제에서 사용하지 않으나, 다른 FRQ에서는 종종 등장하므로 유의.
public int countLongWords(int minLen) {
int count = 0;
for (String w : words) {
if (w.length() >= minLen) {
count++;
}
}
return count;
}
public String firstLetters() {
String result = "";
for (String w : words) {
result += w.substring(0, 1);
}
return result;
}
※ charAt(0) 도 가능하나 char 반환이라 String concat 시 자동 변환됨 (result += w.charAt(0);).
| 구분 | 점수 | 채점 포인트 |
|---|---|---|
| Part A — 1 | +1 | method header 정확 (public int countLongWords(int minLen)) |
| Part A — 2 | +1 | ArrayList traverse (for-each 또는 인덱스 for) |
| Part A — 3 | +1 | w.length() >= minLen 조건 정확 + counter 증가 |
| Part A — 4 | +1 | return count; 정확 |
| Part B — 1 | +1 | method header 정확 (public String firstLetters()) |
| Part B — 2 | +1 | String result 변수 초기화 + 각 word에서 첫 문자 추출 (substring(0,1) 또는 charAt(0)) |
| Part B — 3 | +1 | concatenation + return 정확 |
한국 학생 빈출 감점: ① return 누락 (즉시 0점) ② w.length 괄호 누락 (속성처럼 쓰기) ③ Part B에서 w.substring(1) 같이 잘못 호출 ④ String 비교에 == 사용 (이 문제에는 없지만 빈출).
The StudyTimer class represents a simple study timer that tracks how many minutes a student has studied. Write the complete class based on the following specifications.
Constructor: StudyTimer(String studentName) — creates a new timer for the named student with 0 initial minutes.
Methods:
public void addSession(int minutes) — adds the given minutes to the total. Assume minutes is positive.public int getTotalMinutes() — returns the total minutes studied.public String getReport() — returns a string in the form "name: X min" where X is the total. Example: a timer for "Jeongyeon" with total 45 returns "Jeongyeon: 45 min".Use private instance variables. The class must include a class header, instance variables, constructor, and three methods.
public class StudyTimer {
private String studentName;
private int totalMinutes;
public StudyTimer(String studentName) {
this.studentName = studentName;
this.totalMinutes = 0;
}
public void addSession(int minutes) {
totalMinutes += minutes;
}
public int getTotalMinutes() {
return totalMinutes;
}
public String getReport() {
return studentName + ": " + totalMinutes + " min";
}
}
| 구분 | 점수 | 채점 포인트 |
|---|---|---|
| 1 | +1 | public class StudyTimer class header 정확 |
| 2 | +1 | private instance variables 선언 (String + int) |
| 3 | +1 | constructor 시그니처 + 매개변수 처리 (this. 또는 매개변수명 다르게) |
| 4 | +1 | addSession 시그니처 + totalMinutes 누적 |
| 5 | +1 | getTotalMinutes 시그니처 + return |
| 6 | +1 | getReport 시그니처 + return 정확한 String 형식 |
| 7 | +1 | 전체 구조: class 닫는 중괄호 + 모든 메서드 잘 묶임 + encapsulation 유지 |
한국 학생 빈출 감점: ① instance var를 public으로 선언 (encapsulation 위반) ② constructor 이름 ↔ class 이름 mismatch ③ getReport에서 콜론·공백 형식 누락 ④ this. 누락 시 매개변수가 자기 자신에게 대입.
The QuizScores class stores quiz scores in an ArrayList<Integer>. The class includes the method removeBelow(int passingScore), which removes all scores from the list that are strictly less than passingScore and returns the number of scores removed.
public class QuizScores {
private ArrayList<Integer> scores;
/** Returns the number of scores removed. */
public int removeBelow(int passingScore) { /* to be implemented */ }
}
Example: if scores initially contains [78, 45, 92, 60, 33, 88] and passingScore is 60, after the call scores should contain [78, 92, 60, 88] and the method should return 2.
Implement removeBelow. Avoid ConcurrentModificationException by either iterating in reverse with an index-based loop, or by collecting indices to remove first.
public int removeBelow(int passingScore) {
int count = 0;
for (int i = scores.size() - 1; i >= 0; i--) {
if (scores.get(i) < passingScore) {
scores.remove(i);
count++;
}
}
return count;
}
※ 정방향 + i-- 보정 방식도 가능: for (int i=0; i<scores.size(); ) { if (...) { scores.remove(i); count++; } else { i++; } }
| 구분 | 점수 | 채점 포인트 |
|---|---|---|
| 1 | +1 | method header 정확 (public int removeBelow(int passingScore)) |
| 2 | +1 | ArrayList traverse (역방향 또는 보정 방식 — ConcurrentModification 회피) |
| 3 | +1 | scores.get(i) < passingScore 비교 정확 (Integer auto-unboxing) |
| 4 | +1 | scores.remove(i) + counter 증가 |
| 5 | +1 | return count; 정확 |
한국 학생 빈출 감점: ① for-each + remove → ConcurrentModificationException (런타임 에러로 0점 가능) ② 정방향 + i-- 보정 누락 → 인덱스 시프트로 일부 누락 ③ .size 속성처럼 (괄호 누락) ④ .length 사용 (ArrayList는 메서드 .size()).
The Grid class stores integers in a 2D array int[][] grid. Write the method rowSums that returns a new 1D int array where the i-th element is the sum of row i of grid.
public class Grid {
private int[][] grid;
/** Returns a new int array where element i is the sum of row i. */
public int[] rowSums() { /* to be implemented */ }
}
Example: if grid is
{ {1, 2, 3},
{4, 5, 6},
{7, 8, 9} }
then rowSums() returns {6, 15, 24}.
Assume the grid has at least 1 row and all rows have the same length.
public int[] rowSums() {
int[] sums = new int[grid.length];
for (int i = 0; i < grid.length; i++) {
int sum = 0;
for (int j = 0; j < grid[i].length; j++) {
sum += grid[i][j];
}
sums[i] = sum;
}
return sums;
}
※ 향상된 for(`for-each`)도 가능: 외부는 for (int[] row : grid), 내부는 for (int v : row). 하지만 인덱스 i가 필요하므로 외부는 인덱스 for가 일반적.
| 구분 | 점수 | 채점 포인트 |
|---|---|---|
| 1 | +1 | method header 정확 (public int[] rowSums()) |
| 2 | +1 | 결과 배열 생성 + 크기 grid.length 정확 |
| 3 | +1 | 외부 row 순회 (i) |
| 4 | +1 | 내부 col 순회 (j) + grid[i][j] 인덱스 정확 |
| 5 | +1 | row 합 계산 + sums[i] 대입 |
| 6 | +1 | return sums; 정확 |
한국 학생 빈출 감점: ① grid.length = 행 수 vs grid[0].length = 열 수 혼동 ② row/col 인덱스 swap (grid[j][i]) ③ 결과 배열 크기 잘못 ④ ArrayIndexOutOfBoundsException (jagged array 가정 안 함).