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


patma1981

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

 

Did you know?

The oldest recorded age was 122. Madame Jeanne Calment was born in France in 1875 and died in 1997. She was a vegetarian and loved olive oil, port wine, and chocolate.

Did you know?

The average office desk has 400 times more bacteria on it than a toilet.

Did you know?

Blood is approximately twice as thick as water because of the cells and other components found in it.

Did you know?

In 2010, opiate painkllers, such as morphine, OxyContin®, and Vicodin®, were tied to almost 60% of drug overdose deaths.

Did you know?

For about 100 years, scientists thought that peptic ulcers were caused by stress, spicy food, and alcohol. Later, researchers added stomach acid to the list of causes and began treating ulcers with antacids. Now it is known that peptic ulcers are predominantly caused by Helicobacter pylori, a spiral-shaped bacterium that normally exist in the stomach.

For a complete list of videos, visit our video library