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

Author Question: Analyze the following code:ArrayList list = new ... (Read 42 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


EAN94

  • Member
  • Posts: 307
Reply 3 on: Yesterday
:D TYSM

 

Did you know?

Fewer than 10% of babies are born on their exact due dates, 50% are born within 1 week of the due date, and 90% are born within 2 weeks of the date.

Did you know?

In 2006, a generic antinausea drug named ondansetron was approved. It is used to stop nausea and vomiting associated with surgery, chemotherapy, and radiation therapy.

Did you know?

A serious new warning has been established for pregnant women against taking ACE inhibitors during pregnancy. In the study, the risk of major birth defects in children whose mothers took ACE inhibitors during the first trimester was nearly three times higher than in children whose mothers didn't take ACE inhibitors. Physicians can prescribe alternative medications for pregnant women who have symptoms of high blood pressure.

Did you know?

The liver is the only organ that has the ability to regenerate itself after certain types of damage. As much as 25% of the liver can be removed, and it will still regenerate back to its original shape and size. However, the liver cannot regenerate after severe damage caused by alcohol.

Did you know?

Aspirin is the most widely used drug in the world. It has even been recognized as such by the Guinness Book of World Records.

For a complete list of videos, visit our video library