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

bobbysung

  • Hero Member
  • *****
  • Posts: 519

Question 1

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

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

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

Question 2

Analyze the following code:

public class Test {
public static void main(String[] args) {
int[] x = {0, 1, 2, 3, 4, 5};
xMethod(x, 5);
}

public static void xMethod(int[] x, int length) {
for (int i = 0; i < length; i++)
System.out.print(" " + x[i]);
}
}

◦ The program displays 0 1 2 3 4 and then raises a runtime exception.
◦ The program displays 0 1 2 3 4.
◦ The program displays 0 1 2 3 4 5 and then raises a runtime exception.
◦ The program displays 0 1 2 3 4 5.


Related Topics

Need homework help now?

Ask unlimited questions for free

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

jazzlynnnnn

  • Sr. Member
  • ****
  • Posts: 335
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




bobbysung

  • Member
  • Posts: 519
Reply 2 on: May 6, 2020
Excellent


smrtceo

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

 

Did you know?

In ancient Rome, many of the richer people in the population had lead-induced gout. The reason for this is unclear. Lead poisoning has also been linked to madness.

Did you know?

Barbituric acid, the base material of barbiturates, was first synthesized in 1863 by Adolph von Bayer. His company later went on to synthesize aspirin for the first time, and Bayer aspirin is still a popular brand today.

Did you know?

Methicillin-resistant Staphylococcus aureus or MRSA was discovered in 1961 in the United Kingdom. It if often referred to as a superbug. MRSA infections cause more deaths in the United States every year than AIDS.

Methicilli ...
Did you know?

Cucumber slices relieve headaches by tightening blood vessels, reducing blood flow to the area, and relieving pressure.

Did you know?

Fatal fungal infections may be able to resist newer antifungal drugs. Globally, fungal infections are often fatal due to the lack of access to multiple antifungals, which may be required to be utilized in combination. Single antifungals may not be enough to stop a fungal infection from causing the death of a patient.

For a complete list of videos, visit our video library