250+ TOP MCQs on Structures and Answers

LISP Multiple Choice Questions 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

Answer: b
Clarification: 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: c
Clarification: 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: a
Clarification: 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: c
Clarification: 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: b
Clarification: 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

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

  250+ TOP MCQs on Syntax and Answers

Answer: b
Clarification: 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: d
Clarification: 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: d
Clarification: 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: c
Clarification: This statement will create example field at the employee structure.
Output:
0

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top