DistributedNetworks DistributedNetworks


Shell Variables   «Prev  Next»

Using Numbers in Shell Variables - Quiz

Each question is worth one point. Select the best answer or answers for each question.
 
1. What is the difference between strings and numbers when they are used as variable values?
Please select the best answer.
  A. Strings and numbers in variables are treated the same way, though the operations that can be performed on the variables depend on the value stored in the variable.
  B. Variables that contain numbers must be predefined in order to permit calculations on numeric values. String variables do not require this step.
  C. String variables are referenced using different syntax than numeric variables.
  D. String variables can only be used in certain shells; numeric variables can be used in any shell.

2. What is the meaning of the following statement:
C=‘expr $A \* $B‘

Please select the best answer.
  A. The value of “A modulus B” is calculated by the expr command and assigned to C using a positional variable.
  B. The string “expr $A * $B” is assigned to C because of the quotation marks around it.
  C. This is an invalid syntax in the Bourne shell because it does not support internal calculations.
  D. The value of “A times B” is calculated by the expr command and assigned to C using command substitution.

3. Which of these are valid numeric variable assignments (that is, which variable can subsequently be used in a numeric calculation)?
Please select all the correct answers.
  A. YEAR=”1492”
  B. COUNT=1492
  C. DATE=14JAN
  D. TOTAL=1910934

4. Which of the following statements about string variables are accurate?
Please select all the correct answers.
  A. Only the most basic string manipulations can be performed using shell internal commands.
  B. Only the most basic string manipulations can be performed using external commands.
  C. Shell scripts generally do not need to do a lot of string manipulations.
  D. The shell makes no distinction between variables containing numbers and those containing strings.