adplus-dvertising
frame-decoration

Question

What is the output of the below Java program with command-line arguments?
public class CommandLineArgs1
{
  public static void main(String[] args)
  {
    for(String str: args)
    {
      System.out.println(str);
    }
    if(args.length == 0)
      System.out.println("No arguments passed");
}

c:\folder>java CommandLineArgs1 car brake horn

a.

car brake horn

b.

car
brake
horn

c.

horn brake car

d.

horn
brake
car

Posted under Java Programming

Answer: (b).car
brake
horn

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of the below Java program with command-line arguments?

Similar Questions

Discover Related MCQs

Q. Is there any limit to the number of spaces between two arguments of command-line arguments in Java?

Q. To pass a string as a command-line argument in Java, you need to surround the text within a pair of ___.

Q. Choose the correct way of receiving command-line arguments with in the MAIN method in Java?

Q. Which is the exception or error that is thrown if a non-existing command-line argument is referred to in a Java program?

Q. Any type of data that can be typed on a console or ECLIPSE can be passed as a command-line argument. State TRUE or FALSE.

Q. Which are the methods used to parse string values to the respective data types in Java?

Q. Java Varargs are applicable only for ___.

Q. A Java-Vararg is nothing but ____.

Q. A Java vararg is a ____.

Q. A Java-Vararg can be of any type like primitive or object type. State TRUE or FALSE.

Q. A Java Vararg or Variable Argument can come at any position in a method or constructor. State TRUE or FALSE.

Q. Which is the error thrown when two methods with varargs look the same to the compiler?

Q. Which is the operator used to represent a Vararg type in a method or constructor in Java?

Q. How manymaximum numbers ofVarargs or Variable-Arguments can be there in a method or a constructor in Java?

Q. What is the maximum number of methods or constructors with Varargs in a single Java class?