LISP Multiple Choice Questions on “Properties”.
1. Which procedure is used to create data?
a) List
b) Variable
c) Constructor
d) None of the mentioned
Answer: c
Clarification: A procedure that creates data is a constructor.
2. How many values that a symbol may have?
a) 1
b) 2
c) 3
d) 4
Answer: b
Clarification: Symbols may have property values as well as ordinary values.
3. Which enables storage in symbolically indexed places?
a) Properties
b) Procedures
c) Variable
d) List
Answer: a
Clarification: Properties enables storage in symbolically indexed places.
4. What is the collection of property names and values associated with a symbol?
a) List
b) Property
c) Procedures
d) Property list
Answer: d
Clarification: The collection of property names and values associated with a symbol is sa to be property list.
5. Which is used as writer for properties?
a) Setf
b) Get
c) Both Setf & Get
d) None of the mentioned
Answer: c
Clarification: The setf used together with get, is the writer for properties.
6. What is the output of the given statement?
span class="sy0"> * (setf (get 'patrick 'parents) '(robert dorothy))
a) Robert
b) Dorothy
c) Error
d) Robert Dorothy
Answer: d
Clarification: This statement is used to reterieve the contents from a property.
Output:
(ROBERT DOROTHY)
7. What is the output of the given statement?
span class="sy0"> * (setf (get 'bag 'contents) '(bread butter)) * (get 'bag 'contents)
a) Bread butter
b) Bread
c) Butter
d) None of the mentioned
Answer: a
Clarification: This statement contains get which is used to reterieve the data.
Output:
(BREAD BUTTER)
8. What is the output of the given statement?
span class="sy0"> * (setf (get 'bag 'contents) '(bread butter)) * (get 'bag 'contents) * (remprop 'bag 'contents)
a) Bread
b) Butter
c) (CONTENTS (BREAD BUTTER))
d) None of the mentioned
Answer: c
Clarification: This statement is used to remove the contents from the bag property.
Output:
(CONTENTS (BREAD BUTTER))
9. What is the output of the given statement?
span class="sy0"> * (setf (get 'bag 'contents) '(bread butter)) * (remprop 'bag 'contents) * (get 'bag 'contents)
a) T
b) Nil
c) Bread Butter
d) None of the mentioned
Answer: b
Clarification: This statement will get the content after removing the data, So it is printing as Nil.
Output:
NIL
10. Pick out the correct syntax in given order.
a) (setf (get ) )
b) (setf (get )
c) (setf (get )
d) None of the mentioned
Answer: a
Clarification: The setf and get are used as writer for properties.
