Question: 12. Write a complete method from the implementation perspective called getSomeEntry(). The method will be in the ArrayBag class. ArrayBag implements BagInterface using an array.
12. Write a complete method from the implementation perspective called getSomeEntry(). The method will be in the ArrayBag class.
ArrayBag implements BagInterface using an array.
The method returns an unspecified entry of the ArrayBag. You can decide which entry to return.
Be sure to account for all possible times when the method could be invoked. Your code should not crash.
The method header is:
public T getSomeEntry()
For this question, you are writing code at the implementation level. This means you have access to the private instance data variables:
private T[] bag private int numberOfEntries
You can assume the following methods are already implemented:
public boolean add(T newEntry) public boolean isEmpty() public boolean contains(T anObject) public T remove() public boolean remove(T anEntry) public int getFrequencyOf(T anEntry) public int getCurrentSize() public void clear()
19.
Write a complete method to traverse a linked list of Integers and count the number of even numbers on the list. You are given the first node in the list. The method header is:
public static int countEvens(Nodenode)
You can assume the data and next fields of the Node class are public.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
