LISP Multiple Choice Questions on “Binding”.
1. Which arranges for parameters to be bound on entering a procedure?
a) Form
b) Let
c) Initial
d) Parameter
Answer: b
Clarification: LET arranges for parameters to be bound, just as parameter are bound on entering a procedure.
2. How does LET generally begins with?
a) Parameter list
b) Data
c) Fence
d) None of the mentioned
Answer: a
Clarification: Parameter list consists of two-elements lists, each of which has a parameter variable and an intial value form.
3. What will happen if a variable had not assigned a value by SETF form?
a) Warning
b) Nothing will happen
c) Error message
d) Crash
Answer: c
Clarification: Because of this condition, it will report an unbound variable error.
4. What is the alternative of LET for parameter binding?
a) Let
b) Let*
c) Let^
d) Let%
Answer: b
Clarification: Let* is like shorthand notation for nested LETs.
5. Which helps you to write procedures on complicated things?
a) Development
b) Revoke
c) Progressive envelopment
d) All of the mentioned
Answer: c
Clarification: Progressive envelopment helps you to write procedures on building complicated things incrementally.
6. What is the output of the given statement?
span class="sy0"> * (setf x 'outse) * (let* ((x 'inse) (y x))(list x y))
a) Inse Outse
b) Outse Inse
c) Outse Outse
d) Inse Inse
Answer: d
Clarification: X’s and Y’s parameter are on inse only, So it is printing as Inse Inse.
Output:
(INSE INSE)
7. What is the output of the given statement?
span class="sy0"> * (defun both_ends (whole-list) (let ((element (first whole-list)) (trailer (last whole-list))) (cons element trailer)))
a) Both
b) Both_ends
c) Error
d) None of the mentioned
Answer: b
Clarification: Atfirst element and trailer are assigned to initial value and then element and trailer are combined.
Output:
BOTH_ENDS
8. What is the output of the given statement?
span class="sy0"> * (defun both (l m) (cons (first l) (last m))) * (both '(breakfast lunch) '(tea dinner))
a) Breakfast Lunch
b) Tea Dinner
c) Breakfast
d) Breakfast Dinner
Answer: d
Clarification: The purpose of both is to combine the first element of one list with the last element of another.
Output:
(BREAKFAST DINNER)
9. What is the output of the given statement?
span class="sy0"> * (setf route '(boston cambrge lincoln concord)) * (cons (last route))
a) Boston
b) Cambrge
c) Lincoln
d) Concord
Answer: d
Clarification: This statement will print last element of the list.
Output:
(CONCORD)
10. What is the output of the given statement?
span class="sy0"> * (setf abc-list '(a b c)) * (last abc-list) * (first (last abc-list))
a) A
b) B
c) C
d) None of the mentioned
Answer: c
Clarification: This statement will nest function of last with the first.
Output:
C
