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 60 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
:D TYSM


cici

  • Member
  • Posts: 325
Reply 3 on: Yesterday
Gracias!

 

Did you know?

The Centers for Disease Control and Prevention (CDC) was originally known as the Communicable Disease Center, which was formed to fight malaria. It was originally headquartered in Atlanta, Georgia, since the Southern states faced the worst threat from malaria.

Did you know?

Less than one of every three adults with high LDL cholesterol has the condition under control. Only 48.1% with the condition are being treated for it.

Did you know?

Essential fatty acids have been shown to be effective against ulcers, asthma, dental cavities, and skin disorders such as acne.

Did you know?

People about to have surgery must tell their health care providers about all supplements they take.

Did you know?

GI conditions that will keep you out of the U.S. armed services include ulcers, varices, fistulas, esophagitis, gastritis, congenital abnormalities, inflammatory bowel disease, enteritis, colitis, proctitis, duodenal diverticula, malabsorption syndromes, hepatitis, cirrhosis, cysts, abscesses, pancreatitis, polyps, certain hemorrhoids, splenomegaly, hernias, recent abdominal surgery, GI bypass or stomach stapling, and artificial GI openings.

For a complete list of videos, visit our video library