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 38 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
Thanks for the timely response, appreciate it


epscape

  • Member
  • Posts: 335
Reply 3 on: Yesterday
Great answer, keep it coming :)

 

Did you know?

Computer programs are available that crosscheck a new drug's possible trade name with all other trade names currently available. These programs detect dangerous similarities between names and alert the manufacturer of the drug.

Did you know?

Despite claims by manufacturers, the supplement known as Ginkgo biloba was shown in a study of more than 3,000 participants to be ineffective in reducing development of dementia and Alzheimer’s disease in older people.

Did you know?

Carbamazepine can interfere with the results of home pregnancy tests. If you are taking carbamazepine, do not try to test for pregnancy at home.

Did you know?

Stevens-Johnson syndrome and Toxic Epidermal Necrolysis syndrome are life-threatening reactions that can result in death. Complications include permanent blindness, dry-eye syndrome, lung damage, photophobia, asthma, chronic obstructive pulmonary disease, permanent loss of nail beds, scarring of mucous membranes, arthritis, and chronic fatigue syndrome. Many patients' pores scar shut, causing them to retain heat.

Did you know?

Adolescents often feel clumsy during puberty because during this time of development, their hands and feet grow faster than their arms and legs do. The body is therefore out of proportion. One out of five adolescents actually experiences growing pains during this period.

For a complete list of videos, visit our video library