LISP MCQ set number 00248

1. What is the process of creating new data types in lisp?
a) List
b) Structures
c) Procedures
d) None of the mentioned

Answer

Answer: b [Reason:] Lisp has elaborate apparatus for automatically creating new data types and this is called as structure types.

2. Which is the primitive that creates new structure types?
a) Defnum
b) Deftype
c) Defstruct
d) None of the mentioned

Answer

Answer: c [Reason:] Defstruct is the primitive that creates new structure types.

3. What should be used with structure names with a combination?
a) Make-
b) Make
c) Create
d) Deploy

Answer

Answer: a [Reason:] The defstruct form is evaluated is a combination of make- with structure type’s name.

4. Which enables storage in procedurally indexed places?
a) Defstruct
b) Object
c) Structure
d) None of the mentioned

Answer

Answer: c [Reason:] Structure types enables storage in procedurally indexed places.

5. Which creates reader procedures for getting things out of an instance fields?
a) Structure
b) Defstruct
c) Class
d) Object

Answer

Answer: b [Reason:] None.

6. What is the output of the given statement?

span class="sy0"> * (defstruct person (gender nil) (personality 'nice))
* (setf person-instance-1 (make-person))
* (setf person-instance-2 (make-person :gender 'female))

a) Person :gender female :personality nice
b) Person :gender
c) gender:Female
d) None of the mentioned

Answer

Answer: a [Reason:] This statement will create two entries in the structure named person.
Output:
#S(PERSON :gender FEMALE :PERSONALITY NICE)

7. What is the output of the given statement?

span class="sy0"> * (defstruct person (gender nil) (personality 'nice))
* (setf person-instance-1 (make-person))
* (setf person-instance-2 (make-person :gender 'female))
* (person-personality person-instance-2)

a) Female
b) Nice
c) Person
d) Both Female & Nice

Answer

Answer: b [Reason:] This statement will reveal the value of personality from person.
Output:
NICE

8. What is the output of the given statement?

span class="sy0"> * (defstruct person (gender nil) (personality 'nice))
* (setf person-instance-1 (make-person))
* (setf person-instance-2 (make-person :gender 'female))
* (person-p '(this is a list -- not a person instance))

a) Female
b) Nice
c) T
d) Nil

Answer

Answer: d [Reason:] This statement is based on structure and not on list, So it is printing as nil.
Output:
NIL

9. What is the output of the given statement?

span class="sy0"> * (defstruct person (gender nil) (personality 'nice))
* (setf person-instance-1 (make-person))
* (setf person-instance-2 (make-person :gender 'female))
* (setf (person-surname person-instance-1) 'winston)

a) Winston
b) Nil
c) T
d) Error

Answer

Answer: d [Reason:] The error because of the last statement that the syntax is wrong.

10. What is the output of the given statement?

span class="sy0"> * (defstruct employee (length-of-service 0) (payment 'salary))
* (setf employee-example (make-employee))
* (employee-length-of-service employee-example)

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

Answer

Answer: c [Reason:] This statement will create example field at the employee structure.
Output:
0

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.