Nathan Sprague
9/8/2021
What will be printed when this code executes?
What will be printed when this code executes?
add
Analysisadd
Analysisadd
AnalysisWhat is the worst-case big-
Somewhere in-between?
This table shows the total cost after
assignment cost | resize cost | total | average | |
---|---|---|---|---|
1 | 1 | 0 | 1 | 1 |
2 | 1 | 1 | 3 | 1.5 |
3 | 1 | 2 | 6 | 2 |
4 | 1 | 0 | 7 | 1.75 |
5 | 1 | 4 | 12 | 2.4 |
6 | 1 | 0 | 13 | 2.167 |
7 | 1 | 0 | 14 | 2 |
8 | 1 | 0 | 15 | 1.875 |
9 | 1 | 8 | 24 | 2.667 |
… | … | … | … | … |
Total assignments equal to:
You are performing a code review on the following Java method. This is part of the software that manages an automobile’s safety features. loggingList
is an ArrayList
that stores log messages that will eventually be saved to persistent storage. Which of the following is the most appropriate evaluation of this code?
public static void respondToCollision(Area area) {
loggingList.add("Airbag Depolyed!");
if (area == Area.FRONT)
deployAirbag();
}
area == Area.FRONT
should be area.equals(Area.FRONT)
if
.Space, Right Arrow or swipe left to move to next slide, click help below for more details