Using Objects in AP Computer Science A
What is an object in Java?
An actual instance of an object.
A blueprint for a house.
A template that defines what an object is like and what the object can do.
A reference type that combines primitive and reference data types.
Considering encapsulation principles in OOP, which action should be avoided when dealing with classes and objects?
Allowing direct access modification of class fields from outside methods.
Using getter methods to retrieve field values.
Implementing setter methods that validate data before modifying fields.
Wrapping related variables and methods together into single units as classes.
If two algorithms have been analyzed and one has a complexity classed as while another has , which scenario would likely influence choosing the former over the latter?
Problems where maintaining sorted data elements is not essential
Small-scale applications where execution time differences are negligible
Problems involving large datasets where performance significantly degrades with quadratic complexity
Situations requiring precise control over low-level memory management
Why is understanding recursion relevant when developing algorithms?
Recursion provides a way to solve complex problems by breaking them down into simpler subproblems.
Recursion simplifies debugging by reducing the number of lines in code.
Recursion eliminates the need for data storage in a program.
Recursion speeds up every type of algorithm regardless of context.
When you need to ensure that a section of code executes at least once before checking the continuation condition, which control structure do you use?
do-while loop
while loop
if-else statement
for loop
In a scenario where frequently inserting and deleting elements in the middle of a collection is required, which data structure would be most efficient?
LinkedList
Stack
ArrayList
Array
Assuming class Dog inherits Animal, which of the following illustrates the correct usage of the instanceof operator to determine the type of a reference variable?
instanceof checks while casting an object to a subclass to ensure compatibility.
It provides a mechanism for executing static methods based on their fully-qualified name.
It allows for the conversion of a string representation back to its respective type.
It checks the equality of two distinct objects based on their shared characteristics.

How are we doing?
Give us your feedback and let us know how we can improve
How does throwing an exception within a method affect its execution flow in Java?
When thrown, exceptions run through all remaining lines of code in sequence until they reach end-of-method then propagate upwards if uncaught.
Execution of the method stops immediately, and control transfers to its nearest enclosing try-catch block with a matching catch clause if one exists.
Throwing an exception causes only conditional branching within the same method unless specifically rethrown outside of it.
Exception throwing has no impact on method execution unless explicitly caught within three lines following its declaration or instantiation point.
In Java, what is required to correctly override the equals method for object comparison within a custom class?
The method signature boolean equal(Object obj)
The method signature boolean equals(Object obj)
The method signature void equals(Object obj)
The method signature int equals(Object obj)
When analyzing an algorithm for efficiency, what metric is commonly used to describe its performance as input size grows?
Compilation time
Number of variables
Big O notation
Lines of code