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

Author Question: Do the following two programs produce the same result?Program I:public class Test { public static ... (Read 27 times)

Tazate

  • Hero Member
  • *****
  • Posts: 532
Do the following two programs produce the same result?

Program I:
public class Test {
public static void main(String[] args) {
int[] list = {1, 2, 3, 4, 5};
reverse(list);
for (int i = 0; i < list.length; i++)
System.out.print(list[i] + " ");
}

public static void reverse(int[] list) {
int[] newList = new int[list.length];
for (int i = 0; i < list.length; i++)
newList[i] = list[list.length - 1 - i];
list = newList;
}
}

Program II:
public class Test {
public static void main(String[] args) {
int[] oldList = {1, 2, 3, 4, 5};
reverse(oldList);
for (int i = 0; i < oldList.length; i++)
System.out.print(oldList[i] + " ");
}

public static void reverse(int[] list) {
int[] newList = new int[list.length];
for (int i = 0; i < list.length; i++)
newList[i] = list[list.length - 1 - i];
list = newList;
}
}

◦ Yes
◦ No


Related Topics

Need homework help now?

Ask unlimited questions for free

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

ktidd

  • 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 45% of students answer this correctly




Tazate

  • Member
  • Posts: 532
Reply 2 on: May 6, 2020
Gracias!


peter

  • Member
  • Posts: 330
Reply 3 on: Yesterday
Thanks for the timely response, appreciate it

 

Did you know?

Always store hazardous household chemicals in their original containers out of reach of children. These include bleach, paint, strippers and products containing turpentine, garden chemicals, oven cleaners, fondue fuels, nail polish, and nail polish remover.

Did you know?

Stevens-Johnson syndrome and Toxic Epidermal Necrolysis syndrome are life-threatening reactions that can result in death. Complications include permanent blindness, dry-eye syndrome, lung damage, photophobia, asthma, chronic obstructive pulmonary disease, permanent loss of nail beds, scarring of mucous membranes, arthritis, and chronic fatigue syndrome. Many patients' pores scar shut, causing them to retain heat.

Did you know?

The ratio of hydrogen atoms to oxygen in water (H2O) is 2:1.

Did you know?

About 600,000 particles of skin are shed every hour by each human. If you live to age 70 years, you have shed 105 pounds of dead skin.

Did you know?

Acute bronchitis is an inflammation of the breathing tubes (bronchi), which causes increased mucus production and other changes. It is usually caused by bacteria or viruses, can be serious in people who have pulmonary or cardiac diseases, and can lead to pneumonia.

For a complete list of videos, visit our video library