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
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
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
Explanation: 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
View Answer
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
Explanation: 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
View Answer
Explanation: 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
View Answer
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
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
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
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.
To practice all areas of LISP, here is complete set of 250+ Multiple Choice Questions and Answers on LISP Programming Language.
- Check LISP Books
- Check Computer Science Books
- Apply for Computer Science Internship
- Practice Computer Science MCQs