Unit 7 EXAM (ArrayLists) - REVIEW!!!
Unit 7 EXAM (ArrayLists) - REVIEW!!!
ArrayList
1) Which of the following are true 3) Which of the following is the output
about ArrayList? of the code below?
(B)
(C)
(D)
(A) int
(B) String
(C) Double
(D) Integer
END OF SECTION I
1. This question involves the management of student’s assignments that are represented by the
following Assignment class.
/** Removes an assignment from the assignments list based on inputted name.
* Precondition: All assignments have a unique name – No duplicate names.
*/
public void removeAssignment(String name)
{ /* to be implemented in part (b) */ }
NOTE: Assume the assignments list is already sorted by the daysUntilDue field
value.
{
Assignment(“SampleName1”, “APCS”, 6, “”),
Assignment(“SampleName2”, “APCS”, 8, “”),
Assignment(“SampleName3”, “APCS”, 9, “”),
}
If we run addToAgenda
(Assignment(“SampleName4”, “APCS”, 7, “”));
{
Assignment(“SampleName1”, “APCS”, 6, “”),
Assignment(“SampleName4”, “APCS”, 7, “”),
Assignment(“SampleName2”, “APCS”, 8, “”),
Assignment(“SampleName3”, “APCS”, 9, “”),
}
{
Assignment(“SampleName1”, “APCS”, 6, “”),
Assignment(“SampleName4”, “APCS”, 7, “”),
Assignment(“SampleName5”, “APCS”, 8, “”),
Assignment(“SampleName2”, “APCS”, 8, “”),
Assignment(“SampleName3”, “APCS”, 9, “”),
}
In the case where the daysUntilDue are equal, the new item will be added before the
already existing entries with that value.
public Agenda()
public void addToAgenda(Assignment assignment)
public void removeAssignment(String name)
{
Assignment(“SampleName1”, “APCS”, 6, “”),
Assignment(“SampleName2”, “APCS”, 8, “”),
Assignment(“SampleName3”, “APCS”, 9, “”),
}
If we run removeAssignment(“SampleName2”);
{
Assignment(“SampleName1”, “APCS”, 6, “”),
Assignment(“SampleName3”, “APCS”, 9, “”),
}
public Agenda()
public void addToAgenda(Assignment assignment)
public void removeAssignment(String name)
/** Removes an assignment from the assignments list based on inputted name.
* Precondition: All assignments have a unique name – No duplicate names.
*/
public void removeAssignment(String name)
END OF SECTION II