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


yeungji

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

 

Did you know?

Pregnant women usually experience a heightened sense of smell beginning late in the first trimester. Some experts call this the body's way of protecting a pregnant woman from foods that are unsafe for the fetus.

Did you know?

Between 1999 and 2012, American adults with high total cholesterol decreased from 18.3% to 12.9%

Did you know?

Thyroid conditions may make getting pregnant impossible.

Did you know?

Eating carrots will improve your eyesight. Carrots are high in vitamin A (retinol), which is essential for good vision. It can also be found in milk, cheese, egg yolks, and liver.

Did you know?

The modern decimal position system was the invention of the Hindus (around 800 AD), involving the placing of numerals to indicate their value (units, tens, hundreds, and so on).

For a complete list of videos, visit our video library