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

Author Question: In the following code, what is the printout for list2?class Test { public static void main(String[] ... (Read 52 times)

future617RT

  • Hero Member
  • *****
  • Posts: 543

Question 1

What is the output of the following code?

public class Test {
public static void main(String[] args) {
int list[] = {1, 2, 3, 4, 5, 6};
for (int i = 1; i < list.length; i++)
list[i] = list[i - 1];

for (int i = 0; i < list.length; i++)
System.out.print(list[i] + " ");
}
}

◦ 2 3 4 5 6 1
◦ 1 1 1 1 1 1
◦ 1 2 3 4 5 6
◦ 2 3 4 5 6 6

Question 2

In the following code, what is the printout for list2?

class Test {
public static void main(String[] args) {
int[] list1 = {1, 2, 3};
int[] list2 = {1, 2, 3};
list2 = list1;
list1[0] = 0; list1[1] = 1; list2[2] = 2;
for (int i = 0; i < list2.length; i++)
System.out.print(list2[i] + " ");
}
}

◦ 0 1 3
◦ 1 1 1
◦ 0 1 2
◦ 1 2 3


Related Topics

Need homework help now?

Ask unlimited questions for free

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

Pariscourtney

  • Sr. Member
  • ****
  • Posts: 352
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 56% of students answer this correctly




future617RT

  • Member
  • Posts: 543
Reply 2 on: May 6, 2020
Great answer, keep it coming :)


rleezy04

  • Member
  • Posts: 322
Reply 3 on: Yesterday
YES! Correct, THANKS for helping me on my review

 

Did you know?

The U.S. Pharmacopeia Medication Errors Reporting Program states that approximately 50% of all medication errors involve insulin.

Did you know?

More than 20 million Americans cite use of marijuana within the past 30 days, according to the National Survey on Drug Use and Health (NSDUH). More than 8 million admit to using it almost every day.

Did you know?

Adult head lice are gray, about ? inch long, and often have a tiny dot on their backs. A female can lay between 50 and 150 eggs within the several weeks that she is alive. They feed on human blood.

Did you know?

Patients who have undergone chemotherapy for the treatment of cancer often complain of a lack of mental focus; memory loss; and a general diminution in abilities such as multitasking, attention span, and general mental agility.

Did you know?

Many medications that are used to treat infertility are injected subcutaneously. This is easy to do using the anterior abdomen as the site of injection but avoiding the area directly around the belly button.

For a complete list of videos, visit our video library