250+ TOP MCQs on Setq and Setf and Answers

LISP Multiple Choice Questions on “Setq and Setf”.

1. In the syntax (setf arg1 arg2), what is arg1?
a) Value to be set
b) Variable on which value is set
c) Set of lists
d) Set of elements forming a list

Answer: b
Clarification: The arg1 or argument 1 is like a variable in which value is stored. The arg1 can be anything like a symbol, a list or maybe the first element of a list, etc.

2. In the syntax (setf arg1 arg2), what is arg2?
a) A variable
b) A value to be set on arg1
c) It is the definition of arg1
d) A formula

Answer: b
Clarification: In general, the arg2 or argument2 is the value that is to be set on arg1. It can be a number, a list, a symbol, a formula, etc.

3. What is the notation used for writing LISP Syntax?
a) Prefix
b) Infix
c) Postfix
d) Different notations for different LISP Primitives

Answer: a
Clarification: Prefix notation is always used in LISP Syntax. It doesn’t change for different LISP Primitives. That is infix and postfix notations are not used.

4. What can be used as an argument for a primitive?
a) Atoms and List
b) Another LISP programs
c) A user-defined function
d) Atoms, List, Another LISP program, Used-defined function

Answer: d
Clarification: These all can be used as an argument for a primitive. Arguments depend on the type of primitive used. Example for arithmetic operators: numbers are used. For list functions: lists are used.

5. Choose correct statement about arg1 of setq syntax.
a) It is a list
b) It is a symbol in which value is stored
c) It is an arithmetic operator
d) It is a primitive

  250+ TOP MCQs on String Manipulation and Answers

Answer: b
Clarification: In (setq arg1 arg2), the arg1 is like a variable in which value is stored. It can be a symbol. The value of arg2 got stored in it.

6. What is the value of q after this statement?

a) 2
b) 22
c) 222
d) 3

Answer: a
Clarification: Setf will give the value 2 to q. And q being a variable stores the value in it. And hence it’s value becomes 2.
Output: 2

7. What is the value of p after this statement?

a) 7
b) 3
c) 4
d) Error

Answer: a
Clarification: (+ 3 4) evaluates to 7 and then p is given the value 7.
Output: 7

8. What will be the value of p after the following statement?

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

Answer: a
Clarification: The list is the arg2 of the setq primitive. This list is being stored in the variable p, where p is the arg1 of the setq. There will not be any error as everything is correct.
Output: A B C D

9. What will be stored in tap after the execution of the following statement?

(setf tap (car '(plastic wood)))

a) PLASTIC
b) WOOD
c) PLASTIC WOOD
d) Error

Answer: a
Clarification: The primitive car is used which will take out the first element of the list. So plastic is finally supplied as the value to be stored in variable tap.
Output: PLASTIC.

10. Choose the correct output statement among these.

a) 3.33
b) FLOAT
c) Error
d) 3

Answer: a
Clarification: The floating-point values are also being stored in the variables with the help of setq. And it also shows no error.

Leave a Comment

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

Scroll to Top