Java MCQ Questions - Java Command Line Arguments

This section focuses on the "Command Line Arguments" in Java programming. These Multiple Choice Questions (MCQ) should be practiced to improve the Java programming skills required for various interviews (campus interview, walk-in interview, company interview), placements, entrance exams and other competitive examinations.

1. ____________method can be given parameters via using command line arguments.

A. main()
B. recursive()
C. System defined methods
D. Any method

View Answer


2. Which of these data types is used to store command line arguments?

A. Array
B. Stack
C. String
D. Integer

View Answer


3. Number of arguments can be passed to main() is?

A. 1
B. 2
C. 3
D. Infinite

View Answer


4. args in an array of String.

A. TRUE
B. FALSE
C. Can be true or false
D. Can not say

View Answer


5. What is the output for the following code, when you passed letsfindcourse at run time?

class CommandLineExample{  
public static void main(String args[]){  
System.out.println(""Your first argument is: ""+args[0]);  
}  
}  

A. java
B. CommandLineExample{
C. arg[0]
D. letsfindcourse

View Answer


6. What will be the output of the following Java program, Command line exceution is done as – “java Output This is a command Line”?

    class Output 
    {
        public static void main(String args[]) 
        {
            System.out.print(""args[3]"");
        }
    }

A. java
B. this
C. is
D. command

View Answer


7. Which annotation is used to represent command line input and assigned to correct data type?

A. @Input
B. @Variable
C. @Command Line
D. @Parameter

View Answer


8. ___________ is a very small Java framework that makes it trivial to parse command line parameters.

A. Command Line
B. Jcommander
C. Args
D. None of the above

View Answer


9. Which tab is used to pass command line argument in eclipse?

A. Arguments
B. Variable
C. Both A and B
D. None of the above

View Answer


10. What will be the output of the following Java program?

class abc
{
    public static void main(String args[])
    {
        if(args.length>0)
        System.out.println(args.length);
    }
}

A. The snippet compiles, runs and prints 0
B. The snippet compiles, runs and prints 1
C. The snippet does not compile
D. The snippet compiles and runs but does not print anything

View Answer



Discussion



* You must be logged in to add comment.