Question: Free-Response Questions: Write your answer in the space provided. 1. Write the output of the method: Terminal window printout: (Your answer goes here) 2. Write

Free-Response Questions: Write your answer in the space provided.

Free-Response Questions: Write your answer in the space provided. 1. Write the

1. Write the output of the method: Terminal window printout: (Your answer goes here) 2. Write a method doubleTheList that creates and returns a new ArrayList filled with elements that are twice the value of every element in the parameter ArrayList. Example: ArrayList nums = new ArrayList(); nums.add(3.2); nums.add(2.5); nums.add(-1.1); ArrayList doubleNums = doubleTheList(nums); System.out.println(doubleNums);// prints [6.4, 5.0, -2.2] // pre: numList is not null and has at least one element // post: a new ArrayList containing the values in numList doubled public static ArrayList doubleTheList(ArrayList numList) { }

public static void main() { ArrayList list = new ArrayList(); list.add(2); list.add(0, 3); list.add(1, 4); list.add(3, 5); list.set(2, 7); list.remove(1); list.add(8); System.out.println(list); }

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!