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

Author Question: Analyze the following code:public class Test { public static void main(String[] args) { int[] x = ... (Read 60 times)

Anajune7

  • Hero Member
  • *****
  • Posts: 574

Question 1

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

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 < list1.length; i++)
System.out.print(list1[i] + " ");
}
}

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

Question 2

Analyze the following code:

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

◦ The program displays 1 2 3 4
◦ The program displays 0 0 3 4
◦ The program displays 0 0 0 0
◦ The program displays 0 0


Related Topics

Need homework help now?

Ask unlimited questions for free

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

Alyson.hiatt@yahoo.com

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




Anajune7

  • Member
  • Posts: 574
Reply 2 on: May 6, 2020
YES! Correct, THANKS for helping me on my review


bitingbit

  • Member
  • Posts: 323
Reply 3 on: Yesterday
Excellent

 

Did you know?

The most destructive flu epidemic of all times in recorded history occurred in 1918, with approximately 20 million deaths worldwide.

Did you know?

In most cases, kidneys can recover from almost complete loss of function, such as in acute kidney (renal) failure.

Did you know?

It is believed that the Incas used anesthesia. Evidence supports the theory that shamans chewed cocoa leaves and drilled holes into the heads of patients (letting evil spirits escape), spitting into the wounds they made. The mixture of cocaine, saliva, and resin numbed the site enough to allow hours of drilling.

Did you know?

Amphetamine poisoning can cause intravascular coagulation, circulatory collapse, rhabdomyolysis, ischemic colitis, acute psychosis, hyperthermia, respiratory distress syndrome, and pericarditis.

Did you know?

Of the estimated 2 million heroin users in the United States, 600,000–800,000 are considered hardcore addicts. Heroin addiction is considered to be one of the hardest addictions to recover from.

For a complete list of videos, visit our video library