Bird
0
0

Which of the following is the correct syntax to declare an empty indexed array named numbers in Bash?

easy📝 Syntax Q12 of 15
Bash Scripting - Arrays
Which of the following is the correct syntax to declare an empty indexed array named numbers in Bash?
Anumbers={}
Bnumbers=()
Cnumbers=[]
Dnumbers=""
Step-by-Step Solution
Solution:
  1. Step 1: Recall empty array declaration in Bash

    An empty indexed array is declared with empty parentheses.
  2. Step 2: Evaluate each option

    numbers=() uses empty parentheses correctly. Braces and square brackets are invalid. numbers="" assigns an empty string, not an array.
  3. Final Answer:

    numbers=() -> Option B
  4. Quick Check:

    Empty parentheses declare empty array [OK]
Quick Trick: Empty parentheses mean empty array [OK]
Common Mistakes:
MISTAKES
  • Using square brackets or braces instead of parentheses
  • Assigning empty string instead of array
  • Confusing array declaration with variable assignment

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes