Writing Classes in AP Computer Science A
If you want to ensure that a segment of your class's method code runs at least once before checking its loop condition, which control structure should you use?
do-while loop
recursive method call
standard for loop
for-each loop
What would be the first step when performing a selection sort on this list of integers {8, 4, 5, 1}?
Compare adjacent elements and swap them if they are in the wrong order.
Remove all duplicates from the array before starting any sorting operation.
Find the smallest element (1) and swap it with the first element (8).
Divide the array into two halves before sorting and merging them back together.
Which one of these statements correctly creates an object from the MyClass class in Java?
class MyClassObj = MyClass();
new MyClass();
MakeObject();
MyClass.createObject();
How does implementing a custom exception class enhance the error-handling mechanism provided by the default set of built-in types available in standard libraries found within the development environment, in the context of the learning objectives outlined in the course exam description and related materials?
This suggestion incorrectly presumes that the creation of personal variations somehow weakens the robustness and solidity inherent in the system and undermines its reliability and stability, instead of strengthening areas that might otherwise remain unaddressed or overlooked due to the generic nature of general-purpose offerings.
This simply adds unnecessary complexity, given the wide range of already catered-for common cases that are likely to be encountered, thereby negating the practical value of the addition.
This option indicates a misunderstanding of the purpose behind the ability to declare one's own exceptions, arguing that the practice is discouraged in favor of sticking to the status quo and relying solely on pre-defined solutions offered by the toolkit.
Creating tailored exceptions specifically for the needs of a particular piece of software enables finer granularity in controlling and reacting to various potential hiccups that may arise at runtime. This is especially relevant in contexts where rich user feedback is expected as part of UX/UI considerations, which factor into the overall quality of the end product delivered to consumers.
What is the term for a blueprint in Java that defines a new data type?
Method
Variable
Class
Package
Which of the following is a potential economic impact of technology and computer programs?
Increased reliance on technology in stock trading and economic predictions
Decreased ease of communication between people worldwide
Elimination of the generation gap between younger and older generations
Decreased globalization and cultural mixing
Given a class hierarchy where Animal
is a superclass and Dog
, Cat
, and Bird
are subclasses, which method implementation would correctly override a superclass method to provide specific functionality for the Dog
class while ensuring encapsulation?
public void makeSound() { System.out.println("Bark!"); }
public String makeSound() { return "Bark!"; }
void makeSound() { System.out.println("Bark!"); }
private void makeSound() { System.out.println("Woof!"); }

How are we doing?
Give us your feedback and let us know how we can improve
Which of the following isn't part of a class?
Variable declarations
Constructors
Methods
Interfaces
Which of the following is a potential social implication of computing systems?
Inability to communicate with people worldwide
Limited cultural mixing and globalization
Decreased reliance on technology in stock trading
Generation gap between younger and older generations
What is one consideration for programmers regarding system reliability?
System reliability is not a concern for programmers
Bugs in the code should not be fixed once detected
All systems have the same inherent security issues
Different devices may perform the same task at different speeds and in different ways