Java MCQs on Command Line Arguments in Java Programming Language.
1. Which of this method is given parameter via command line arguments? Answer: a 2. Which of these data types is used to store command line arguments? Answer: c 3. How many arguments can be passed to main()? Answer: a 4. Which of these is a correct statement about args in the following line of code? a) args is a String Answer: c 5. Can command line arguments be converted into int automatically if required? Answer: b 6. What will be the output of the following Java program, Command line execution is done as – “java Output This is a command Line”? a) java 7. What will be the output of the following Java program, Command line exceution is done as – “java Output This is a command Line”? a) java 8. What will be the output of the following Java program, Command line execution is done as – “java Output This is a command Line”? a) This 9. What will be the output of the following Java program, Command line execution is done as – “java Output command Line 10 A b 4 N”? a) java 10. What will be the output of the following Java program, Command line execution is done as – “java Output command Line 10 A b 4 N”? a) java
a) main()
b) recursive() method
c) Any method
d) System defined methods
Clarification: Only main() method can be given parameters via using command line arguments.
a) Array
b) Stack
c) String
d) Integer
Clarification: None.
a) Infinite
b) Only 1
c) System Dependent
d) None of the mentioned
Clarification: None.public static void main(String args[])
b) args is a Character
c) args is an array of String
d) args in an array of Character
Clarification: args in an array of String.
a) Yes
b) No
c) Compiler Dependent
d) Only ASCII characters can be converted
Clarification: All command Line arguments are passed as a string. We must convert numerical value to their internal forms manually.
class Output
{
public static void main(String args[])
{
System.out.print("args[0]");
}
}
b) Output
c) This
d) is
Clarification: None.
Output:
$ javac Output.javac
java Output This is a command Line
This
class Output
{
public static void main(String args[])
{
System.out.print("args[3]");
}
}
b) is
c) This
d) command
Clarification: None.
Output:
$ javac Output.javac
java Output This is a command Line
command
class Output
{
public static void main(String args[])
{
System.out.print("args");
}
}
b) java Output This is a command Line
c) This is a command Line
d) Compilation Error
Clarification: None.
Output:
$ javac Output.javac
java Output This is a command Line
This is a command Line
class Output
{
public static void main(String args[])
{
System.out.print("(int)args[2] * 2");
}
}
b) 10
c) 20
d) b
Clarification: None.
Output:
$ javac Output.javac
java Output command Line 10 A b 4 N
20
class Output
{
public static void main(String args[])
{
System.out.print("args[6]");
}
}
b) 10
c) b
d) N
Clarification: None.
Output:
$ javac Output.javac
java Output command Line 10 A b 4 N
N