250+ TOP MCQs on LISP Class and Answers

LISP Multiple Choice Questions on “Class”.

1. Which makes it possible to define generic functions?
a) Lisp
b) CLOS
c) Class
d) Object-Oriented programming

Answer: b
Clarification: Common Lisp Object System makes it possible to define generic functions.

2. What is meant by collection of methods the same name?
a) Lisp class
b) Class
c) Generic function
d) None of the mentioned

Answer: c
Explanaton: Each collection of methods that share the same name is called a generic function.

3. Which keyword is used to define the method?
a) Defun
b) Destruct
c) Demake
d) Defmethod

Answer: d
Clarification: Defmethod is used for defining the method.

4. Which class can help to select a method?
a) Nonoptional argument
b) Class
c) Method
d) None of the mentioned

Answer: a
Clarification: Any nonoptional argument class can help to select a method.

5. Which require sophisticated precedence computation?
a) Superclass
b) Multiple Superclass
c) Subclass
d) None of the mentioned

Answer: b
Clarification: Multiple superclasses require sophisticated precedence computations.

6. What is the output of the given statement?

span class="sy0"> * (defstruct triangle (base 0) (altitude 0))
* (defun area (figure) (cond ((triangle-p figure) (* 1/2 (triangle-base figure) (triangle-altitude figure)))))
* (setf triangle (make-triangle :base 2 :altitude 3))
* (area triangle)

a) Triangle
b) 7
c) 3
d) 10

Answer: c
Clarification: This statement will compute the area of triangle.
Output:
3

7. What is the output of the given statement?

span class="sy0"> * (defstruct circle (radius 0))
* (defun area (figure) (cond ((circle-p figure) (* pi (expt (circle-radius figure) 2)))))
* (setf circle (make-circle :radius 11))
* (area circle)

a) 44
b) 380
c) 382
d) 380.132

Answer: d
Clarification: This statement will compute the area of circle using given statement.
Output:
380.132711084365

  250+ TOP MCQs on S-Expression and Answers

8. What is the output of the given statement?

span class="sy0"> * (defmethod area ((figure rectangle)) (* (rectangle-wth figure) (rectangle-height figure)))

a) Area
b) Rectangle
c) Height
d) Error

Answer: d
Clarification: This statement will return an error because of misplacing of brackets.

9. What is the output of the given statement?

span class="sy0"> * (defclass article() ((title :accessor article-title :initarg :title) (author :accessor article-author :initarg :author)))

a) Article
b) <STANDARD-CLASS
c)
d) None of the mentioned

Answer: c
Clarification: This statement will create an class by using defclass keyword.
Output:
#

10. What is the output of the given statement?

span class="sy0"> * (defclass article() ((title :accessor article-title :initarg :title) (author :accessor article-author :initarg :author)))
* (defclass computer-article (article) ())
* (defclass business-article (article) ())
* (defclass political-article (article) ())
* (setf articles (list (make-instance 'business-article :title "Memory Prices down")))

a) Business article
b) Political article
c) Business article
d)

Answer: d
Clarification: This statement will make the book name under the main title of business articles.
Output:
(#)

Leave a Comment

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

Scroll to Top