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 53 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
YES! Correct, THANKS for helping me on my review


connor417

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

 

Did you know?

More than 4.4billion prescriptions were dispensed within the United States in 2016.

Did you know?

When blood is deoxygenated and flowing back to the heart through the veins, it is dark reddish-blue in color. Blood in the arteries that is oxygenated and flowing out to the body is bright red. Whereas arterial blood comes out in spurts, venous blood flows.

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.

Did you know?

There are immediate benefits of chiropractic adjustments that are visible via magnetic resonance imaging (MRI). It shows that spinal manipulation therapy is effective in decreasing pain and increasing the gaps between the vertebrae, reducing pressure that leads to pain.

Did you know?

Pope Sylvester II tried to introduce Arabic numbers into Europe between the years 999 and 1003, but their use did not catch on for a few more centuries, and Roman numerals continued to be the primary number system.

For a complete list of videos, visit our video library