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 35 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
:D TYSM


apple

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

 

Did you know?

When blood is exposed to air, it clots. Heparin allows the blood to come in direct contact with air without clotting.

Did you know?

Drug abusers experience the following scenario: The pleasure given by their drug (or drugs) of choice is so strong that it is difficult to eradicate even after years of staying away from the substances involved. Certain triggers may cause a drug abuser to relapse. Research shows that long-term drug abuse results in significant changes in brain function that persist long after an individual stops using drugs. It is most important to realize that the same is true of not just illegal substances but alcohol and tobacco as well.

Did you know?

Anesthesia awareness is a potentially disturbing adverse effect wherein patients who have been paralyzed with muscle relaxants may awaken. They may be aware of their surroundings but unable to communicate or move. Neurologic monitoring equipment that helps to more closely check the patient's anesthesia stages is now available to avoid the occurrence of anesthesia awareness.

Did you know?

Bacteria have flourished on the earth for over three billion years. They were the first life forms on the planet.

Did you know?

Medication errors are more common among seriously ill patients than with those with minor conditions.

For a complete list of videos, visit our video library