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

Author Question: Analyze the following two programs:A:public class Test { public static void main(String[] args) { ... (Read 36 times)

Sportsfan2111

  • Hero Member
  • *****
  • Posts: 585
Analyze the following two programs:

A:

public class Test {
public static void main(String[] args) {
xMethod(5);
}

public static void xMethod(int length) {
if (length > 1) {
System.out.print((length - 1) + " ");
xMethod(length - 1);
}
}
}

B:
public class Test {
public static void main(String[] args) {
xMethod(5);
}

public static void xMethod(int length) {
while (length > 1) {
System.out.print((length - 1) + " ");
xMethod(length - 1);
}
}
}

◦ The two programs produce the same output 4 3 2 1.
◦ The two programs produce the same output 1 2 3 4.
◦ Program A produces the output 4 3 2 1 and Program B prints 4 3 2 1 1 1 .... 1 infinitely.
◦ The two programs produce the same output 5 4 3 2 1.
◦ The two programs produce the same output 1 2 3 4 5.


Related Topics

Need homework help now?

Ask unlimited questions for free

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

Viet Thy

  • Sr. Member
  • ****
  • Posts: 329
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




Sportsfan2111

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


triiciiaa

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

 

Did you know?

Astigmatism is the most common vision problem. It may accompany nearsightedness or farsightedness. It is usually caused by an irregularly shaped cornea, but sometimes it is the result of an irregularly shaped lens. Either type can be corrected by eyeglasses, contact lenses, or refractive surgery.

Did you know?

There are 60,000 miles of blood vessels in every adult human.

Did you know?

Alcohol acts as a diuretic. Eight ounces of water is needed to metabolize just 1 ounce of alcohol.

Did you know?

If you use artificial sweeteners, such as cyclamates, your eyes may be more sensitive to light. Other factors that will make your eyes more sensitive to light include use of antibiotics, oral contraceptives, hypertension medications, diuretics, and antidiabetic medications.

Did you know?

Essential fatty acids have been shown to be effective against ulcers, asthma, dental cavities, and skin disorders such as acne.

For a complete list of videos, visit our video library