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


nanny

  • Member
  • Posts: 313
Reply 3 on: Yesterday
Excellent

 

Did you know?

Signs of depression include feeling sad most of the time for 2 weeks or longer; loss of interest in things normally enjoyed; lack of energy; sleep and appetite disturbances; weight changes; feelings of hopelessness, helplessness, or worthlessness; an inability to make decisions; and thoughts of death and suicide.

Did you know?

Human neurons are so small that they require a microscope in order to be seen. However, some neurons can be up to 3 feet long, such as those that extend from the spinal cord to the toes.

Did you know?

The most destructive flu epidemic of all times in recorded history occurred in 1918, with approximately 20 million deaths worldwide.

Did you know?

In 2006, a generic antinausea drug named ondansetron was approved. It is used to stop nausea and vomiting associated with surgery, chemotherapy, and radiation therapy.

Did you know?

Drug-induced pharmacodynamic effects manifested in older adults include drug-induced renal toxicity, which can be a major factor when these adults are experiencing other kidney problems.

For a complete list of videos, visit our video library