Writing Classes in AP Computer Science A
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
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.
What is the term for the smallest unit of data in a computer system?
Megabyte
Kilobyte
Byte
Bit
What do we call functions defined within a class in Java?
Methods
Commands
Procedures
Sequences
Which of these variable declarations uses appropriate naming conventions in Java?
double AccountBalance;
double accountBalance;
double ACCOUNT_BALANCE;
double account_balance;
Which keyword creates an instance of an object from a class?
.new
class
extend
this
What type of error does the compiler detect if a method is capable of throwing a checked exception, but it is not handled or declared in a throws clause?
Compile-time error
Runtime error
Logic error
Syntax error

How are we doing?
Give us your feedback and let us know how we can improve
Given the following method definition: public static boolean isEven(int a) { return (a % 2 == 0); }
All array's elements are even
Integers are odd
Integers are even
All array's elements are odd
Considering encapsulation best practices for classes CustomerAccount and PremiumCustomerAccount where PremiumCustomerAccount extends CustomerAccount, which field declaration supports proper encapsulation?
public int accountNumber; // In CustomerAccount class
double rewardsPoints; // In PremiumCustomerAccount class
private String email; // In PremiumCustomerAccount class but getter/setter in CustomerAccount
protected double balance; // In CustomerAccount class
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)