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

Author Question: Which code fragment would correctly identify the number of arguments passed via the command line to ... (Read 44 times)

chads108

  • Hero Member
  • *****
  • Posts: 507

Question 1

Given the following program:

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

What is the output, if you run the program using the following?

java Test 1 2 3

◦ 1 2
◦ 1
◦ 1 2 3
◦ 3

Question 2

Which code fragment would correctly identify the number of arguments passed via the command line to a Java application, excluding the name of the class that is being invoked?
◦ int count=0; while (!(args[count].equals(""))) count ++;
◦ int count = args.length - 1;
◦ int count = args.length;
◦ int count = 0; while (args[count] != null) count ++;


Related Topics

Need homework help now?

Ask unlimited questions for free

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

coreycathey

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




chads108

  • Member
  • Posts: 507
Reply 2 on: May 6, 2020
Excellent


billybob123

  • Member
  • Posts: 336
Reply 3 on: Yesterday
Wow, this really help

 

Did you know?

Asthma-like symptoms were first recorded about 3,500 years ago in Egypt. The first manuscript specifically written about asthma was in the year 1190, describing a condition characterized by sudden breathlessness. The treatments listed in this manuscript include chicken soup, herbs, and sexual abstinence.

Did you know?

Lower drug doses for elderly patients should be used first, with titrations of the dose as tolerated to prevent unwanted drug-related pharmacodynamic effects.

Did you know?

In ancient Rome, many of the richer people in the population had lead-induced gout. The reason for this is unclear. Lead poisoning has also been linked to madness.

Did you know?

Vampire bats have a natural anticoagulant in their saliva that permits continuous bleeding after they painlessly open a wound with their incisors. This capillary blood does not cause any significant blood loss to their victims.

Did you know?

In the ancient and medieval periods, dysentery killed about ? of all babies before they reach 12 months of age. The disease was transferred through contaminated drinking water, because there was no way to adequately dispose of sewage, which contaminated the water.

For a complete list of videos, visit our video library