The classjava .util .Vector implements a growable array of objects. Here is a subset of the methods available in the classjava. util. Vector:
Constructors
Vector();
// Constructs an empty vector.
Vector(int initialCapacity,int capacitylncrement)
// Constructs an empty vector with the specified // initial capacity and capacity increment.
Methods
void addElement(Object obj);
// Adds the specified component to the end of this // vector, increasing its size by one.
int capacity();
// Returns the current capacity of this vector.
Object elementAt(int index);
// Returns the component at the specified index,void removeElementAt(int index);
// Deletes the component at the specified index, int size();
// Returns the number of components in this vector.
Complete the following tasks:
a. Declare a vectorfirst with an initial capacity of 10 and a capacity increment of 5. Write afor loop that initializes all ten elements of the vector to the integers 1 through 10. What do the methodssize andcapacity return?
b. Add four more integers to the vectorfirst. What do the methods size andcapacity return now?
c. Write a loop to print all of the elements stored in the vectorfirst.
d. Declare a vectorsecond using the default constructor. What doescapacity return in this case? Write a loop to add elements to the vectorsecond so that this capacity is exceeded by one. What is the new capacity?
e. Delete all of the elements from the vectorsecond. Does the capacity change? Why do you think theVector class behaves this way?
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.