Using Objects in AP Computer Science A
What do you necessarily need to provide when calling any non-default constructor or non-void methods/parameters in your program?
Nothing, a blank parenthesis is sufficient.
Default values allow omission provided.
Exact number of type each parameter required.
Just variable names associated with those types.
If you must choose between two void methods with parameters that manipulate data structures—one employing tail recursion and another utilizing head recursion—which should generally be prioritized for efficiency reasons?
The tail-recursive method since some compilers can optimize tail calls into iterations avoiding additional stack frames.
Neither—both types of recurrences have identical efficiencies across all scenarios.
The head-recursive method because recursive calls are placed first enabling quicker access to subsequent operations.
In what scenario would calling updateRecord(void recordUpdater(), String id) cause potential issues without proper validation checks inside recordUpdater()?
When printing confirmation messages after successful updates.
When formatting output before displaying updated record information.
When id refers to nonexistent records.
When updating fields within existing records.
If we call printSum(5,10);
assuming it's properly defined elsewhere in our program, what would be expected to happen next?
It waits for additional inputs before executing.
It prints "5+10" as text on screen without calculation.
The printSum method executes using arguments 5
and 10
.
It returns some numerical result back to where it was called from.
In order to process multiple conditions where each condition has its separate set of actions to perform, which control structure would typically be most efficient?
if-else chain
logical operator ( && or ||) based expressions
nested switch statements
recursive method calls
Given an existing “Vehicle” class, which scenario demonstrates using composition as opposed to inheritance when introducing “Engine” behavior?
Embedding an "Engine" object within both "Car" and "Boat" classes separately.
Defining an "AmphibiousCar" that inherits from both "Car" and "Boat".
Having an abstract method in "Vehicle" overridden by specific implementations in its subclasses like “Airplane”.
Creating sub-classes "Car" and "Boat" that extend "Vehicle", each with unique propulsion methods.
Given a void method configure(Settings setup)
in a base class Device
, how should it be called correctly from within another void method initialize()
of its subclass 'Smartphone' without altering the original settings object passed as an argument?
super.configure(new Settings(setup))
configure(this.setup)
super.configure(setup.clone())
this.configure(new Settings(setup))

How are we doing?
Give us your feedback and let us know how we can improve
If you want to ensure that your program checks at least once whether certain conditions are met before executing related tasks, which control structure would be most appropriate?
infinite loop
traditional while loop
unconditional goto statement
do-while loop
What type of control structure would best allow a method to choose among many possible execution paths based on the value of a single variable?
for-each loop
switch statement
if-else chain
do-while loop
When would using a RuntimeException in a method signature be appropriate?
When errors are due to programming mistakes such as illegal method calls or incorrect array indexing.
When dealing with I/O operations that might not always behave predictably.
When you need to indicate a failure related to user input that needs validation.
When there's a need for checked exceptions that must be declared or handled.