This topic contains a solution. Click here to go to the answer

Author Question: Analyze the following code:ArrayList list = new ... (Read 62 times)

jon_i

  • Hero Member
  • *****
  • Posts: 549

Question 1

Invoking ________ returns the number of the elements in an ArrayList x.
◦ x.getSize()
◦ x.size()
◦ x.length(1)
◦ x.getLength(0)

Question 2

Analyze the following code:

ArrayList list = new ArrayList();
list.add("Beijing");
list.add("Tokyo");
list.add("Shanghai");
list.set(3, "Hong Kong");

◦ If you replace the last line by list.add(3, "Hong Kong"), the code will compile and run fine.
◦ The last line in the code causes a runtime error because there is no element at index 3 in the array list.
◦ The last line in the code has a compile error because there is no element at index 3 in the array list.
◦ If you replace the last line by list.add(4, "Hong Kong"), the code will compile and run fine.


Related Topics

Need homework help now?

Ask unlimited questions for free

Ask a Question
Marked as best answer by jon_i on May 6, 2020

yeungji

  • Sr. Member
  • ****
  • Posts: 319
Lorsum iprem. Lorsus sur ipci. Lorsem sur iprem. Lorsum sur ipdi, lorsem sur ipci. Lorsum sur iprium, valum sur ipci et, vala sur ipci. Lorsem sur ipci, lorsa sur iprem. Valus sur ipdi. Lorsus sur iprium nunc, valem sur iprium. Valem sur ipdi. Lorsa sur iprium. Lorsum sur iprium. Valem sur ipdi. Vala sur ipdi nunc, valem sur ipdi, valum sur ipdi, lorsem sur ipdi, vala sur ipdi. Valem sur iprem nunc, lorsa sur iprium. Valum sur ipdi et, lorsus sur ipci. Valem sur iprem. Valem sur ipci. Lorsa sur iprium. Lorsem sur ipci, valus sur iprem. Lorsem sur iprem nunc, valus sur iprium.
Answer Preview
Only 25% of students answer this correctly




jon_i

  • Member
  • Posts: 549
Reply 2 on: May 6, 2020
YES! Correct, THANKS for helping me on my review


mammy1697

  • Member
  • Posts: 341
Reply 3 on: Yesterday
Great answer, keep it coming :)

 

Did you know?

Recent studies have shown that the number of medication errors increases in relation to the number of orders that are verified per pharmacist, per work shift.

Did you know?

Acetaminophen (Tylenol) in overdose can seriously damage the liver. It should never be taken by people who use alcohol heavily; it can result in severe liver damage and even a condition requiring a liver transplant.

Did you know?

Many of the drugs used by neuroscientists are derived from toxic plants and venomous animals (such as snakes, spiders, snails, and puffer fish).

Did you know?

Medications that are definitely not safe to take when breastfeeding include radioactive drugs, antimetabolites, some cancer (chemotherapy) agents, bromocriptine, ergotamine, methotrexate, and cyclosporine.

Did you know?

Pregnant women usually experience a heightened sense of smell beginning late in the first trimester. Some experts call this the body's way of protecting a pregnant woman from foods that are unsafe for the fetus.

For a complete list of videos, visit our video library