AP Computer Science A
Java ile programlama: nesneler ve metotlar, koşullar ve döngüler, sınıf yazma, diziler ve ArrayList, özyineleme, arama ve sıralama.
AP Computer Science A (Java)
Java dilinde nesne yönelimli programlama, sınıf tasarımı (Classes), String ve koleksiyon (ArrayList, 2D array) algoritmaları, özyineleme ve arama/sıralama. 2025-26 CED (College Board ders çerçevesi)'de kalıtım (Inheritance) kapsam dışıdır.
Binary Search: O(log N) | Merge Sort: O(N log N)
Unit 1: Using Objects and Methods
Değişkenler, ifadeler, nesne oluşturma ve metot çağırma; String nesnesi ve metotları. Çoktan seçmeli bölümün kod izleme sorularının temeli.
A String is an immutable object: every method returns a new value and never changes the original. Indices start at 0, and substring(a, b) includes index a but excludes index b, so its length is b − a. indexOf(str) returns the index of the first occurrence, or −1 if str is not found. compareTo returns a negative, zero, or positive int based on character codes, and every uppercase letter comes before every lowercase letter.
s1.equals(s2) compares the characters; s1 == s2 only asks whether both variables refer to the same object. A String built at run time (for example "A" + w.substring(1)) is a new object, so == can be false even when the text is identical.
w.substring(1); on its own line changes nothing. Only an assignment such as w = w.substring(1); updates the variable.
Unit 1 Using Objects and Methods: İnteraktif Soru İstasyonu
Özgün AP tarzı sorular (geçmiş sınav sorusu değil). Şık seç; anında çözüm ve hata türü gelir.
Unit 2 Selection and Iteration: İnteraktif Soru İstasyonu
Boolean ifadeler, if / else, while ve for döngüleri, iç içe döngüler ve String üzerinde algoritmalar.
Unit 3: Class Creation
Sınıf yazma: örnek değişkenleri, kurucular, erişim ve değiştirme metotları, kapsülleme, this, statik üyeler ve referanslar.
extends, super, overriding, polymorphic references) is outside the scope of the AP CSA course and exam, so this page has no new inheritance questions. Kaynak: College Board, AP CSA Revisions ve AP CSA Course (13 Ekim 2026'da kontrol edildi).
A well-designed class keeps its instance variables private (encapsulation) and exposes behavior through public constructors, accessors, and mutators. A constructor has the class name and no return type; it initializes every instance variable. If a class defines any constructor, Java does not add a no-argument default constructor, so new Book() fails when only Book(String, int) exists. A void method returns nothing and cannot be used inside an expression such as println(...).
Counter c2 = c1; both variables are aliases of one object.
null and testing x == null are safe; calling a method on null (for example x.length()) throws a NullPointerException. The empty String "" is a real object with length 0.
The 4 Pillars of OOP in Java:
1. Encapsulation: Instance variables declared private, accessed solely through public accessor (getter) and mutator (setter) methods to protect internal object state.
2. Inheritance: A subclass inherits public and protected members of a superclass via the extends keyword. The subclass constructor must invoke super(...) as its very first statement. (Scope note: implementing inheritance is outside the 2025-26 AP CSA course and exam; it remains useful background for university Java courses.)
3. Polymorphism (also beyond the 2025-26 exam scope): An object reference of a superclass type can point to an instance of any subclass:
SuperClass obj = new SubClass(); $\implies$ Method execution is determined at runtime via dynamic method lookup.
4. Abstraction: Abstract classes and interfaces specifying method signatures without concrete implementation.
arr.length). ArrayList<E> is dynamically resizable and stores only object references (using auto-boxing for primitives: Integer, Double). When removing elements from an ArrayList, always loop from back to front (for (int i = list.size() - 1; i >= 0; i--)) to prevent skipping adjacent elements!
Unit 3 Class Creation: İnteraktif Soru İstasyonu
Özgün AP tarzı sorular (geçmiş sınav sorusu değil). Şık seç; anında çözüm ve hata türü gelir.
Unit 4: Data Collections
Diziler, ArrayList, 2B diziler, özyineleme, arama ve sıralama: çoktan seçmeli bölümün en ağır ünitesi (%30–40).
add(obj) appends; add(i, obj) inserts at index i and shifts later elements right; remove(i) deletes and shifts later elements left; set(i, obj) replaces without shifting. Rewrite the whole list after every call: the second remove works on the already shifted list.
for (int i = list.size() - 1; i >= 0; i--)) or decrement i after each removal. After inserting at index i, increase i once more so the same element is not processed again. The condition i < list.size() is re-evaluated on every iteration.
ArrayList inside a for-each loop throws a ConcurrentModificationException. For arrays of primitives, assigning to the for-each variable changes only a copy.
new int[rows][cols] creates an array of rows. grid.length is the number of rows and grid[0].length is the number of columns. Row-major traversal uses the row index in the outer loop; column-major traversal uses the column index in the outer loop. Default element values are 0, 0.0, false, or null.
for (int c = r; ...)), each row visits a different number of cells: this traces the upper triangle including the main diagonal. Sketch the grid and mark the visited cells before adding anything.
Every recursive method needs a base case that returns without another call and a recursive step that moves toward it. Trace with one line per call, going down until the base case, then combine return values on the way back up. Statements written after the recursive call run during this unwinding, so output appears in reverse order.
mid = (lo + hi) / 2 and recurses on one half. When the target is absent, the search ends with a call where lo > hi, and that call counts too. Merge sort splits the array in half recursively and merges the sorted halves.
Linear search checks elements in order and returns the first matching index (or −1); it works on unsorted data. Binary search requires sorted data and halves the range each step. Selection sort finds the minimum of the unsorted part and swaps it into position j, so after k passes the first k elements are final. Insertion sort shifts larger elements right and inserts the current element, so after k passes the first k + 1 elements are sorted among themselves.
Big-O Asymptotic Running Time:
• Sequential (Linear) Search: $O(N)$ best for unsorted arrays.
• Binary Search: $O(\log N)$ requires a pre-sorted array, halving search space at each iteration.
• Selection Sort & Insertion Sort: $O(N^2)$ worst and average case quadratic time.
• Merge Sort: $O(N \log N)$ recursive divide-and-conquer algorithm; consistent performance across all data distributions.
StackOverflowError.
Unit 4 Data Collections: İnteraktif Soru İstasyonu
Özgün AP tarzı sorular (geçmiş sınav sorusu değil). Kodlu sorular çalıştırılarak doğrulandı.
Java FRQ Kod Yazım Kuralları
• NullPointerException ve ArrayIndexOutOfBounds hatalarına karşı döngü sınırlarını (i < arr.length) kontrol et.
• Sınıf içi private değişkenlere doğrudan değil, getter/setter metotlarıyla eriş.
• equals() vs == farkını String karşılaştırmasında asla unutma!