LISP Questions & Answers – Structures

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

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

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

Answer: a
Explanation: The defstruct form is evaluated is a combination of make- with structure type’s name.
advertisement

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

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

Answer: b
Explanation: Defstruct creates a constructor procedure. Defstruct creates reader procedures for getting things out of an instance fields.
Free 30-Day Java Certification Bootcamp is Live. Join Now!

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

Answer: a
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?

advertisement
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

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

Answer: d
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

Answer: d
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

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

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
I’m Manish - Founder and CTO at Sanfoundry. I’ve been working in tech for over 25 years, with deep focus on Linux kernel, SAN technologies, Advanced C, Full Stack and Scalable website designs.

You can connect with me on LinkedIn, watch my Youtube Masterclasses, or join my Telegram tech discussions.

If you’re in your 40s–60s and exploring new directions in your career, I also offer mentoring. Learn more here.