Writing Classes in AP Computer Science A
Why would you choose a recursive solution instead of iterative for solving certain problems?
To ensure compatibility across different programming languages, as recursion is universally supported.
To express complex problems more simply when there are clear base cases and recursive steps.
To minimize execution time, regardless of the nature of the problem being solved.
To reduce memory usage since recursion requires less storage space than iteration.
Assuming complex logic inside their methods, how does declaring related exception handling impact robustness when designing two independent classes, FileParser and NetworkConnector, both containing critical operation methods?
void performCriticalOperation(); // No declared exceptions for either class
void performCriticalOperation() throws Exception {} // For both classes
void performFileParsing() throws FileNotFoundException {}; void establishConnection() throws SocketException {};
void performCriticalOperation() throws IOException, NetworkFailureException {} // For both classes
What is a common operation performed to retrieve an element at a specific index from an ArrayList in Java?
set(index, element)
get(index)
remove(index)
add(element)
What is the term for the smallest unit of data in a computer system?
Megabyte
Kilobyte
Byte
Bit
Which value can a boolean variable have in Java?
true or false
on or off
yes or no
positive or negative
What do we call functions defined within a class in Java?
Methods
Commands
Procedures
Sequences
Considering a recursive function designed to find permutations of string characters, which conditional statement ensures unique permutations are accounted for when duplicate characters exist in the input string?
if(chars.length % i == startIndex) continue;
if(chars[startIndex] == chars[i]) continue;
if(Collections.frequency(charsList, chars[i]) > startIndex) continue;
if(i > startIndex && chars[i] == chars[i - 1]) continue;

How are we doing?
Give us your feedback and let us know how we can improve
In object-oriented programming, what do we call data encapsulated within classes?
Attributes
Fields
Elements
Properties
Which of these variable declarations uses appropriate naming conventions in Java?
double AccountBalance;
double accountBalance;
double ACCOUNT_BALANCE;
double account_balance;
In Java, which scenario best demonstrates polymorphism?
Using different classes that implement a common interface and calling methods defined by that interface
- Casting from one class type into another within a hierarchy
- Adding elements of different but related types into a standard java.util.ArrayList
- Answering calls with multiple parameters through method overloading