This set of LISP Multiple Choice Questions & Answers (MCQs) focuses on “Structures”.
1. What is the process of creating new data types in lisp?
a) List
b) Structures
c) Procedures
d) None of the mentioned
View Answer
Explanation: 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
View Answer
Explanation: 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
View Answer
Explanation: 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
View Answer
Explanation: 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
View Answer
Explanation: Defstruct creates a constructor procedure. Defstruct creates reader procedures for getting things out of an instance fields.
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
View Answer
Explanation: 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
View Answer
Explanation: 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
View Answer
Explanation: 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
View Answer
Explanation: 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
View Answer
Explanation: This statement will create example field at the employee structure.
Output:
0
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.
If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]
- Check Computer Science Books
- Apply for Computer Science Internship
- Practice Computer Science MCQs
- Check LISP Books