Bird
0
0

Find the error in this script snippet:

medium📝 Debug Q7 of 15
Bash Scripting - Variables
Find the error in this script snippet:
VAR=50
readonly VAR
VAR+=10
echo $VAR
AVAR is not readonly yet
BSyntax error in VAR+=10
CNo error, output is 60
DCannot append to a readonly variable
Step-by-Step Solution
Solution:
  1. Step 1: VAR is set to 50 and made readonly

    Readonly locks the variable value.
  2. Step 2: Attempt to append 10 to VAR

    Appending fails because variable is readonly and cannot be changed.
  3. Final Answer:

    Cannot append to a readonly variable -> Option D
  4. Quick Check:

    Readonly variables cannot be modified or appended [OK]
Quick Trick: Readonly variables cannot be changed or appended [OK]
Common Mistakes:
MISTAKES
  • Expecting VAR+=10 to work on readonly
  • Thinking += is invalid syntax
  • Assuming output is sum

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes