Workshop
The workshop is designed to help you anticipate possible questions, review what you've learned, and begin putting your knowledge into practice.
Quiz
1: | Which of the following variable names is not valid?
|
2: | What will the following code fragment output?
|
3: | What will the following statement output?
|
4: | What will be the output from the following code fragment?
|
5: | Which of the following statements does not contain an expression?
|
6: | Which of the statements in question 5 contains an operator? |
7: | What value will the following expression return?
What data type will the returned value be? |
Answers
A1: | The variable name $666666xyz is not valid because it does not begin with a letter or an underscore character. The variable name $the first is not valid because it contains a space. $file-name is also invalid because it ontains a non-alphanumeric character. |
A2: | The fragment will print the integer 33. The cast to Boolean produces a converted copy of the value stored in $num. It does not alter the value actually stored there. |
A3: | The statement will output the string "string". |
A4: | The code will output the value 5. When a double is converted to an integer, any information beyond the decimal point is lost. |
A5: | They are all expressions because they all resolve to values. |
A6: | The statement 5/12; contains a division operator. |
A7: | The expression will resolve to false, which is a Boolean value. |