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 49 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


bulacsom

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

 

Did you know?

Historic treatments for rheumatoid arthritis have included gold salts, acupuncture, a diet consisting of apples or rhubarb, nutmeg, nettles, bee venom, bracelets made of copper, prayer, rest, tooth extractions, fasting, honey, vitamins, insulin, snow collected on Christmas, magnets, and electric convulsion therapy.

Did you know?

The top 10 most important tips that will help you grow old gracefully include (1) quit smoking, (2) keep your weight down, (3) take supplements, (4) skip a meal each day or fast 1 day per week, (5) get a pet, (6) get medical help for chronic pain, (7) walk regularly, (8) reduce arguments, (9) put live plants in your living space, and (10) do some weight training.

Did you know?

The first documented use of surgical anesthesia in the United States was in Connecticut in 1844.

Did you know?

Most fungi that pathogenically affect humans live in soil. If a person is not healthy, has an open wound, or is immunocompromised, a fungal infection can be very aggressive.

Did you know?

When intravenous medications are involved in adverse drug events, their harmful effects may occur more rapidly, and be more severe than errors with oral medications. This is due to the direct administration into the bloodstream.

For a complete list of videos, visit our video library