LISP MCQ set number 00227

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

Answer

Answer: b [Reason:] 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

Answer: c [Reason:]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

Answer: d [Reason:] 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

Answer: a [Reason:] Any nonoptional argument class can help to select a method.

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

Answer

Answer: b [Reason:] None.

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) 6
d) 10

Answer

Answer: c [Reason:] This statement will compute the area of triangle.
Output:
6

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

Answer: d [Reason:] 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

Answer

Answer: d [Reason:] 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

Answer

Answer: c [Reason:] 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) <BUSINESS-ARTICLE {Random Number}>

Answer

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

ed010d383e1f191bdb025d5985cc03fc?s=120&d=mm&r=g

DistPub Team

Distance Publisher (DistPub.com) provide project writing help from year 2007 and provide writing and editing help to hundreds student every year.