Bird
0
0

Why does Java use String[] args in the main method to access command-line arguments instead of a List or other collection?

hard📝 Conceptual Q10 of 15
Java - Command Line Arguments
Why does Java use String[] args in the main method to access command-line arguments instead of a List or other collection?
ABecause List is not available in Java standard library
BBecause arrays are simple, fixed-size, and directly supported by JVM
CBecause main method cannot accept objects
DBecause String[] args allows dynamic resizing
Step-by-Step Solution
Solution:
  1. Step 1: Understand JVM and main method requirements

    The JVM expects main method to have a fixed signature with String array parameter for command-line arguments.
  2. Step 2: Reason why arrays are used

    Arrays are simple, fixed-size, and directly supported by JVM at startup, unlike collections which require extra setup.
  3. Final Answer:

    Because arrays are simple, fixed-size, and directly supported by JVM -> Option B
  4. Quick Check:

    JVM requires fixed signature with String array for main method [OK]
Quick Trick: JVM requires fixed main method signature with String array [OK]
Common Mistakes:
  • Thinking List is unavailable in Java
  • Believing main cannot accept objects
  • Assuming String[] args is dynamically resizable

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Java Quizzes