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 38 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
Great answer, keep it coming :)


vickybb89

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

 

Did you know?

Approximately 25% of all reported medication errors result from some kind of name confusion.

Did you know?

Pubic lice (crabs) are usually spread through sexual contact. You cannot catch them by using a public toilet.

Did you know?

Throughout history, plants containing cardiac steroids have been used as heart drugs and as poisons (e.g., in arrows used in combat), emetics, and diuretics.

Did you know?

Your chance of developing a kidney stone is 1 in 10. In recent years, approximately 3.7 million people in the United States were diagnosed with a kidney disease.

Did you know?

Medications that are definitely not safe to take when breastfeeding include radioactive drugs, antimetabolites, some cancer (chemotherapy) agents, bromocriptine, ergotamine, methotrexate, and cyclosporine.

For a complete list of videos, visit our video library