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

Author Question: What is the output of the following code?public class Test { public static void main(String[] args) ... (Read 39 times)

KimWrice

  • Hero Member
  • *****
  • Posts: 579

Question 1

What is the output of the following code?

int[] myList = {1, 2, 3, 4, 5, 6};

for (int i = myList.length - 2; i >= 0; i--) {
myList[i + 1] = myList[i];
}

for (int e: myList)
System.out.print(e + " ");

◦ 1 2 3 4 5 6
◦ 6 1 2 3 4 5
◦ 2 3 4 5 6 1
◦ 6 2 3 4 5 1
◦ 1 1 2 3 4 5

Question 2

What is the output of the following code?

public class Test {
public static void main(String[] args) {
int[] x = {120, 200, 016};
for (int i = 0; i < x.length; i++)
System.out.print(x[i] + " ");
}
}

◦ 120 200 14
◦ 120 200 16
◦ 120 200 20
◦ 016 is a compile error. It should be written as 16.


Related Topics

Need homework help now?

Ask unlimited questions for free

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

Shshxj

  • 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 39% of students answer this correctly




KimWrice

  • Member
  • Posts: 579
Reply 2 on: May 6, 2020
:D TYSM


amcvicar

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

 

Did you know?

In women, pharmacodynamic differences include increased sensitivity to (and increased effectiveness of) beta-blockers, opioids, selective serotonin reuptake inhibitors, and typical antipsychotics.

Did you know?

Cytomegalovirus affects nearly the same amount of newborns every year as Down syndrome.

Did you know?

There are approximately 3 million unintended pregnancies in the United States each year.

Did you know?

In most climates, 8 to 10 glasses of water per day is recommended for adults. The best indicator for adequate fluid intake is frequent, clear urination.

Did you know?

Most strokes are caused when blood clots move to a blood vessel in the brain and block blood flow to that area. Thrombolytic therapy can be used to dissolve the clot quickly. If given within 3 hours of the first stroke symptoms, this therapy can help limit stroke damage and disability.

For a complete list of videos, visit our video library