273). Which of this method is given parameter via command line arguments?
[A]main()
[B]recursive() method
[C] Any method
[D]System defined methods
Show Answer
Correct Answer: main()
Notes:
Answer: a
Explanation: Only main() method can be given parameters via using command line arguments.
274). Which of these data types is used to store command line arguments?
[A]Array
[B]Stack
[C]String
[D]Integer
Show Answer
Correct Answer: String
Notes:
Answer: c
Explanation: None.
275). How many arguments can be passed to main()?
[A]Infinite
[B] Only 1
[C]System Dependent
[D]None of the mentioned
Show Answer
Correct Answer: Infinite
Notes:
Answer: a
Explanation: None.
276). Which of these is a correct statement about args in the following line of code?
public static void main(String args[])
[A]args is a String
[B]args is a Character
[C]args is an array of String
[D]args in an array of Character
Show Answer
Correct Answer: args is an array of String
Notes:
Answer: c
Explanation: args in an array of String.
277). Can command line arguments be converted into int automatically if required?
public static void main(String args[])
[A]Yes
[B]No
[C]Compiler Dependent
[D]Only ASCII characters can be converted
Show Answer
Correct Answer: No
Notes:
Answer: b
Explanation: All command Line arguments are passed as a string. We must convert numerical value to their internal forms manually.
278). What will be the output of the following Java program, Command line execution is done as – “java Output This is a command Line”?
class Output
{
public static void main(String args[])
{
System.out.print(args[0]);
}
}
[A]java
[B]Output
[C]This
[D]is
Show Answer
Correct Answer: This
Notes:
Answer: c
Explanation: None.
Output:$ javac Output.javac
java Output This is a command Line
This
279). 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]is
[C]This
[D]command
Show Answer
Correct Answer: command
Notes:
Answer: d
Explanation: None.
Output:
$ javac Output.javac
java Output This is a command Line
command
280). What will be the output of the following Java program, Command line execution is done as – java Output “This is a command Line”?
class Output
{
public static void main(String args[])
{
for (String arg : args)
{
System.out.print(arg);
}
}
}
[A]This
[B]java Output This is a command Line
[C] This is a command Line
[D]Compilation Error
Show Answer
Correct Answer: This is a command Line
Notes:
Answer: c
Explanation: None.
Output:
$ javac Output.javac
java Output This is a command Line
This is a command Line
281). 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”?
class Output
{
public static void main(String args[])
{
System.out.print((int)args[2] * 2);
}
}
[A]java
[B]10
[C]20
[D]error
Show Answer
Correct Answer: error
Notes:
Answer: d
Explanation: None.
Output:
$ javac Output.javac
error: incompatible types: String cannot be converted to int
282). 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”?
class Output
{
public static void main(String args[])
{
System.out.print(args[6]);
}
}
Show Answer
Correct Answer: N
Notes:
Answer: d
Explanation: None.
Output:
$ javac Output.javac
java Output command Line 10 A b 4 N
N