Question

Describe the effect of each of the following operations on object myList . What is the...

Describe the effect of each of the following operations on object myList .

What is the value of myList.size() after each operation?

Figure the initial list consist of the following string names:

Bashful

Awful

Doc

Jumpy

Happy

Dopey.

Answer both questions.

myList.add("Pokey");

myList.add("Campy");

int i = myList.indexOf("Happy");

myList.set(i, "Bouncy");

myList.remove(myList.size() - 2);

String temp = myList.get(1);

myList.set(1, temp.toUpperCase());

Homework Answers

Answer #1

Solution

Starting size is 6

myList.add("Pokey");

It add elements to end of the "myList"

after adding size is 7

myList.add("Campy");

It add elements to end of the "myList"

after adding size is 8

int i = myList.indexOf("Happy");

it returns the value 4 and it stored to integer 'i"

myList.set(i, "Bouncy");

then we set the element i(4) to "Bouncy" and size is 8

myList.remove(myList.size() - 2);

it will remove the item 6 that is "Pokey" and size is 7

String temp = myList.get(1);

now it will store "awful" in temp and size is 7

myList.set(1, temp.toUpperCase());

Now sets item1 to "AWFUL" and replacing "awful

therefore

final size is 7

---

all the best

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Do a theta analysis and count the number of computations it performed in each function/method of...
Do a theta analysis and count the number of computations it performed in each function/method of the following code: import java.io.*; import java.util.Scanner; class sort { int a[]; int n; long endTime ; long totalTime; long startTime; static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); public sort(int nn) // Constructor { a = new int[nn]; n = nn; endTime= 0; totalTime =0; startTime =0; } public static void main(String args[]) throws IOException { System.out.print("\nEnter number of students: "); int nn =...
IN JAVA Iterative Linear Search, Recursive Binary Search, and Recursive Selection Sort: <-- (I need the...
IN JAVA Iterative Linear Search, Recursive Binary Search, and Recursive Selection Sort: <-- (I need the code to be written with these) I need Class river, Class CTRiver and Class Driver with comments so I can learn and better understand the code I also need a UML Diagram HELP Please! Class River describes river’s name and its length in miles. It provides accessor methods (getters) for both variables, toString() method that returns String representation of the river, and method isLong()...
C++ See the provided specification files. Complete the implementation for each as a separate file. void...
C++ See the provided specification files. Complete the implementation for each as a separate file. void seen(std::string); If there is already a Word object in the Words list, then the number of occurrences for this word is incremented. If there is no Word object for this word already, create a new word object with occurrence =1, and insert this object into the list of Word objects. std::string getNextWord(); Returns the next word of the list and sets the currentItem pointer...
Describe how one can implement each of the following operations on an array so that the...
Describe how one can implement each of the following operations on an array so that the time it takes does not depend on the array’s size n. a. Delete the $i$th element of an array ($1\leq i \leq n$). b. Delete the $i$th element of a sorted array (the remaining array has to stay sorted).
Java question, Please answer everything. Thank you Answer the following questions as briefly (but completely) as...
Java question, Please answer everything. Thank you Answer the following questions as briefly (but completely) as possible: What is a checked exception, and what is an unchecked exception? What is NullPointerException? Which of the following statements (if any) will throw an exception? If no exception is thrown, what is the output? 1: System.out.println( 1 / 0 ); 2: System.out.println( 1.0 / 0 ); Point out the problem in the following code. Does the code throw any exceptions? 1: long value...
8.15 *zyLab: Method Library (Required & Human Graded) This code works but there are some problems...
8.15 *zyLab: Method Library (Required & Human Graded) This code works but there are some problems that need to be corrected. Your task is to complete it to course style and documentation standards CS 200 Style Guide. This project will be human graded. This class contains a set of methods. The main method contains some examples of using the methods. Figure out what each method does and style and document it appropriately. The display method is done for you and...
Create a simple Java class for a Month object with the following requirements:  This program...
Create a simple Java class for a Month object with the following requirements:  This program will have a header block comment with your name, the course and section, as well as a brief description of what the class does.  All methods will have comments concerning their purpose, their inputs, and their outputs  One integer property: monthNumber (protected to only allow values 1-12). This is a numeric representation of the month (e.g. 1 represents January, 2 represents February,...
For each of the following situations, describe the anticipated effect on blood pressure and the physiological...
For each of the following situations, describe the anticipated effect on blood pressure and the physiological basis of the response: (1) anticipation to giving a lecture/speech/presentation, (2) cardiac arrest, (3) atherosclerosis, and (4) femoral artery bleed.
Modify the following code by JAVA language Write a static method totalDurations that is passed the...
Modify the following code by JAVA language Write a static method totalDurations that is passed the parallel arrays from the main program. It creates a new pair of parallel arrays (phone numbers and durations, again) where each different incoming phone number is stored exactly once, and the duration is the total duration of all the calls from that phone number. It then prints these arrays. Nothing is returned. For example, if the arrays contain 555-1234 (duration 10), 555-4321 (duration 20),...
I need a method for public void ****************** write the method “insertDoubles” that for each value...
I need a method for public void ****************** write the method “insertDoubles” that for each value found in an integer linked list it inserts that value doubled after the original. The method should return nothing and take in in no parameters. If the list is empty, then the method should do nothing. To avoid infinite loops you need to move the iterator past the newly inserted value. here is the provided code public class Question02 { public class ListNode//public for...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT