Question: In java: Suppose the following method is added to the ArrayIntList class: public void mystery() { int n = 0; for (int i = 0;

In java:

Suppose the following method is added to the ArrayIntList class:

public void mystery() {
 int n = 0;
 for (int i = 0; i < size; i++) {
 n += elementData[i] * i;
 }
 elementData[size] = n;
 size++;
}

What is the output of the following client code?

ArrayIntList list = new ArrayIntList();
list.add(14);
list.add(3);
list.add(6);
list.add(2);
list.mystery();
System.out.println("list = " + list);
System.out.println("size = " + list.size());

line 1
line 2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!