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 29 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


dyrone

  • Member
  • Posts: 322
Reply 3 on: Yesterday
YES! Correct, THANKS for helping me on my review

 

Did you know?

The modern decimal position system was the invention of the Hindus (around 800 AD), involving the placing of numerals to indicate their value (units, tens, hundreds, and so on).

Did you know?

Egg cells are about the size of a grain of sand. They are formed inside of a female's ovaries before she is even born.

Did you know?

The first oncogene was discovered in 1970 and was termed SRC (pronounced "SARK").

Did you know?

The longest a person has survived after a heart transplant is 24 years.

Did you know?

Illicit drug use costs the United States approximately $181 billion every year.

For a complete list of videos, visit our video library