Java Multiple Choice Questions & Answers on Command Line Arguments for Freshers

1. Which of these method is given parameter via command line arguments?

a) main().
b) recursive() method.
c) Any method.
d) System defined methods.
Answer: a

Explanation: Only main() method can be given parameters via using command line arguments.
2. Which of these data types is used to store command line arguments?

a) Array
b) Stack
c) String
d) Integer
Answer: c
3. How many arguments can be passed to main()?

a) Infinite
b) Only 1
c) System Dependent
d) None of the mentioned
Answer: a
4. Which of these is a correct statement about args in this line of code?
public static viod 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.
Answer: c

Explanation: args in an array of String.
5. Can command line arguments be converted into int automatically if required?

a) Yes
b) No
c) Compiler Dependent
d) Only ASCII characters can be converted.
Answer: b

Explanation: All command Line arguments are passed as a string. We must convert numerical value to their internal forms manually.
6. What is the output of this program, Command line execution is done as – “java Output This is a command Line”?
  1.     class Output {
  2.         public static void main(String args[]) {
  3.             System.out.print("args[0]");
  4.         }
  5.     }
a) java
b) Oupput
c) This
d) is
Answer: c
7. What is the output of this program, Command line exceution is done as – “java Output This is a command Line”?
  1.     class Output {
  2.         public static void main(String args[]) {
  3.             System.out.print("args[3]");
  4.         }
  5.     }
a) java
b) is
c) This
d) command
Answer: d
8. What is the output of this program, Command line execution is done as – “java Output This is a command Line”?
  1.     class Output {
  2.         public static void main(String args[]) {
  3.             System.out.print("args");
  4.         }
  5.     }
a) This
b) java Output This is a command Line
c) This is a command Line
d) Compilation Error
Answer: c
9. What is the output of this program, Command line execution is done as – “java Output command Line 10 A b 4 N”?
  1.     class Output {
  2.         public static void main(String args[]) {
  3.             System.out.print("(int)args[2] * 2");
  4.         }
  5.     }
a) java
b) 10
c) 20
d) b
Answer: c
10. What is the output of this program, Command line execution is done as – “java Output command Line 10 A b 4 N”?
  1.     class Output {
  2.         public static void main(String args[]) {
  3.             System.out.print("args[6]");
  4.         }
  5.     }
a) java
b) 10
c) b
d) N
Answer: d

Related

C# Questions & Answers on Arithmetic Operators for Freshers

1. Predict the output for the following set of code. static void Main(string[] args) { float a = 16.4f; int b = 12; float c; c = a * ( b + a) / (a - b) ; ...

Cloud Computing Questions and Answers on Introduction to Cloud Computing for Freshers

1. _________ computing refers to applications and services that run on a distributed network using virtualized resources. a) Distributedb) Cloudc) Softd) Parallel Answer: b Explanation: Cloud Com...

C# Questions & Answers onType Conversion in Expressions for Freshers

1. What is the need for ‘Conversion of data type’ in C#? a) To store a value of one data type into a variable of another data typeb) To get desired datac) To prevent situations of run time error ...

Post a Comment

emo-but-icon
:noprob:
:smile:
:shy:
:trope:
:sneered:
:happy:
:escort:
:rapt:
:love:
:heart:
:angry:
:hate:
:sad:
:sigh:
:disappointed:
:cry:
:fear:
:surprise:
:unbelieve:
:shit:
:like:
:dislike:
:clap:
:cuff:
:fist:
:ok:
:file:
:link:
:place:
:contact:

item