LISP Questions & Answers – Class

This set of LISP Multiple Choice Questions & Answers (MCQs) focuses on “Class”.

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

Answer: b
Explanation: 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
View Answer

Answer: c
Explanation: 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
View Answer

Answer: d
Explanation: Defmethod is used for defining the method.
advertisement
advertisement

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

Answer: a
Explanation: 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
View Answer

Answer: b
Explanation: Multiple superclasses require sophisticated precedence computations.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

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
View Answer

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

7. What is the output of the given statement?

advertisement
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
View Answer

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

8. What is the output of the given statement?

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

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

Answer: d
Explanation: 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) <STANDARD-CLASS ARTICLE>
d) None of the mentioned
View Answer

Answer: c
Explanation: This statement will create an class by using defclass keyword.
Output:
#<STANDARD-CLASS ARTICLE>

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) <BUSINESS-ARTICLE {Random Number}>
View Answer

Answer: d
Explanation: This statement will make the book name under the main title of business articles.
Output:
(#<BUSINESS-ARTICLE {AC04B11}>)

Sanfoundry Global Education & Learning Series – LISP Programming Language.

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.