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 30 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
Excellent


softEldritch

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

 

Did you know?

There are actually 60 minerals, 16 vitamins, 12 essential amino acids, and three essential fatty acids that your body needs every day.

Did you know?

The National Institutes of Health have supported research into acupuncture. This has shown that acupuncture significantly reduced pain associated with osteoarthritis of the knee, when used as a complement to conventional therapies.

Did you know?

Cyanide works by making the human body unable to use oxygen.

Did you know?

The average adult has about 21 square feet of skin.

Did you know?

According to the CDC, approximately 31.7% of the U.S. population has high low-density lipoprotein (LDL) or "bad cholesterol" levels.

For a complete list of videos, visit our video library