250+ TOP MCQs on Lexical Variables and Answers

LISP Multiple Choice Questions on “Lexical Variables”.

1. Which makes it possible to define sophisticated generator procedures that produce new values?
a) List
b) Variables
c) Encapsulation
d) None of the mentioned

Answer: c
Clarification: Encapsulation makes it possible to define sophisticated generator procedures that produce new values each time they are called.

2. Which primitive enables you to define one procedure inse another?
a) Do
b) List
c) Primitive
d) Labels

Answer: d
Clarification: The labels primitive enables you to define one procedure inse another.

3. Which helps to produce nested fences?
a) Lets
b) List
c) Label
d) None of the mentioned

Answer: a
Clarification: Lets helps to produce nested fences.

4. Which do not produce nested fences?
a) Variables
b) Procedure calls
c) Fences
d) All of the mentioned

Answer: b
Clarification: Procedure calls do not produce nested fences.

5. Which makes nameless procedures into lexical closures?
a) $
b) #
c) #’
d) *

Answer: c
Clarification: #’ makes it possible to produce nameless procedures into lexical closures.

6. What is the output of the given statement?

span class="sy0"> * (defun first-of-first-with-labels (l) (labels ((aux (m) (first m))) (first (aux 1))))
* (first-of-first-with-labels '((a b) (c d)))

a) A
b) B
c) C
d) D

Answer: a
Clarification: This statement will produce the result as first given variable.
Output:
A

7. What is the output of the given statement?

span class="sy0"> * (defun power-of-two () (setf previous-power-of-two (* previous-power-of-two 2)))
* (power-of-two)
* (power-of-two)

a) 1
b) 2
c) 4
d) None of the mentioned

Answer: c
Clarification: This statement will compute the power of two by executing certain number of times.
Output:
4

8. What is the output of the given statement?

span class="sy0"> * (defun square (list-of-numbers) (mapcar #'(lambda (n) (*n n)) list-of-numbers))
* (square '(1 2 3))

a) 9
b) 1
c) 3
d) 1 4 9

  250+ TOP MCQs on Predicates and Answers

Answer: d
Clarification: This statement will compute the square of all given numbers.
Output:
(1 4 9)

9. What is the output of the given statement?

span class="sy0"> * (setf square-procedures #'(lambda (n) (* n n)))
* (funcall square-procedure 2)

a) 1
b) 2
c) 3
d) 4

Answer: d
Clarification: This statement will compute the procedure of square using the given statement.
Output:
4

10. What is the output of the given statement?

span class="sy0"> * (setf g1 (let ((previous-power-of-two 1)) #'(lambda () (setf previous-power-of-two (*previous-power-of-two 2)))))
* (g1)

a) G1
b) 0
c) Let
d) Error

Answer: d
Clarification: This statement will create an error because of lag in number of arguments.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top