250+ TOP MCQs on Predicates and Answers

LISP Questions and Answers for Entrance exams on “Predicates”.

1. Which of the following is used by member primitive to compare arguments?
a) =
b) equalp
c) equal
d) eql

Answer: d
Clarification: Eql is used by member argument to compare between its two arguments. Eql is one of the equality predicates and is used to test for numbers and symbols of the same type.

2. Which among these are the data type predicates?
a) atom
b) symbolp
c) listp & numberp
d) atom, symbol, listp & numberp

Answer: d
Clarification: Atom, symbolp, listp, numberp all are consered as data type predicates. Atom is used check if an argument is atom or not. Similarly, symbolp is used to check symbols, listp to check lists and numberp to check whether the argument is a number or not.

3. What is the use of zerop?
a) To check object is zero
b) To check object is NIL
c) To make non-zero object to zero
d) It is same as integerp

Answer: a
Clarification: It is the predicate used to check whether the argument is zero or not. It will show T (true) only if the argument is numeric zero, that is, 0 and NIL in all other cases.

4. Integerp and Zerop will be same __
a) When argument is not an integer or equal to 0
b) When argument is not equal to 0
c) When argument is a negative integer
d) When argument is a negative integer and not 0

Answer: a
Clarification: Both integerp and zerop will be same when both will show either T or NIL. Both will show T when argument is 0 and NIL when argument is not an integer.

  250+ TOP MCQs on LISP Class and Answers

5. What will be the output of the following LISP statement?

(evenp (zerop (* 0 234)))

a) T
b) NIL
c) error
d) 0

Answer: c
Clarification: Error will occur because zerop will give T as an argument to evenp which is not a number and hence evenp will not work.

6. What is the output of the following LISP statement?

a) T
b) NIL
c) Number is too large
d) Error

Answer: a
Clarification: evenp work on negative numbers also. As the number is even so, the output is T.
Output: T

7. What is the output of the following LISP statement? (NOTE: Here * refers to a new line)

(defun rock() (setq p 8))
*(cons NIL (oddp (rock)))

a) NIL . NIL
b) ERROR
c) T . NIL
d) NIL

Answer: d
Clarification: Cons primitive is used to make construct of two arguments given to it. Generally, the cons of A & B is (A . B) but for two NILs it will show only NIL.
Output: NIL

8. What will be the output of the following statement?

a) Error due to T and NIL are not lists
b) T
c) NIL
d) T . NIL

Answer: b
Clarification: The cons of T & NIL is not (T . NIL). In this statement the T will dominate above NIL and thus T . NIL gives T on construct.
Output: T

9. What will be the output of the following program?

(defun root() (setq qw 'a))
*(equalp (root) 'a)

a) (cons NIL NIL)
b) T
c) NIL
d) Error

Answer: b
Clarification: The function root will return ‘a after execution. Now, this is given as argument to equalp predicate. As both the arguments are ‘a so, the equalp will return T as output.
Output: T

  250+ TOP MCQs on String Manipulation and Answers

10. What will be the output of the following statement?

(cons (car '(a b)) (cdr '(p q)))

a) P . Q
b) A . B
c) A . Q
d) A . P

Answer: c
Clarification: car will give the first element of the list. So, one argument becomes A. cdr will give all elements except first element of the list. So, the second argument becomes Q. The cons of A and Q becomes A . Q
Output: A . Q

Leave a Comment

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

Scroll to Top