LISP Questions & Answers – Array

This set of LISP Multiple Choice Questions & Answers (MCQs) focuses on “Array”.

1. What is a data type in which expressions are stored in places identified by integer indexes?
a) Structure
b) List
c) Array
d) None of the mentioned
View Answer

Answer: c
Explanation: An array is a data type in which expressions are stored in places identified by integer indexes.

2. Which symbol holds the first element and also an index?
a) Nail
b) Tail
c) Initial
d) All of the mentioned
View Answer

Answer: a
Explanation: The nails symbol indicates the first bin, the one with an index of 0 holds nails.

3. Which keyword is used to construct an array?
a) Array
b) Make-array
c) Bins
d) Make
View Answer

Answer: b
Explanation: The array can be constructed and its dimension can be set by using make-array.
advertisement
advertisement

4. Which is present in the writer procedure for arrays?
a) Setf
b) Aref
c) Fref
d) Both Setf & Aref
View Answer

Answer: d
Explanation: setf is writer procedure and aref is reader procedure for arrays.

5. Which keyword embeds the initial element in an array?
a) Initial
b) Initial-content
c) Initial-element
d) None of the mentioned
View Answer

Answer: b
Explanation: Initial-Contents keyword along with the desired intial elements wrapped up in an array.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

6. What is the output of the given statement?

span class="sy0"> * (Setf part-bins (make-array '(4)))

a) #Done
b) #4
c) #(0 0 0 0)
d) None of the mentioned
View Answer

Answer: c
Explanation: This statement will create an array of elements and everything will be initialized to zero.
Output:
#(0 0 0 0)
advertisement

7. What is the output of the given statement?

advertisement
span class="sy0"> * (setf bins (make-array 2 :initial-element 'e))

a) E
b) E E
c) E E E
d) E E E E
View Answer

Answer: b
Explanation: This statement will create an array and initialize the array to E.
Output:
#(E E)

8. What is the output of the given statement?

span class="sy0"> * (setf part (make-array '(8 8)))

a) 8
b) 0 0 0 0 0 0 0 0
c) 0 0 0 0
d) 8 rows of 0
View Answer

Answer: d
Explanation: This statement will create an two-dimensional array and initialize the element to 0.
Output:
#2A((0 0 0 0 0 0 0 0)
(0 0 0 0 0 0 0 0)
(0 0 0 0 0 0 0 0)
(0 0 0 0 0 0 0 0)
(0 0 0 0 0 0 0 0)
(0 0 0 0 0 0 0 0)
(0 0 0 0 0 0 0 0)
(0 0 0 0 0 0 0 0))

9. What is the output of the given statement?

span class="sy0"> * (setf bins (make-array 4 :initial-element 'e))
* (aref bins 0)

a) E
b) 0
c) 4
d) None of the mentioned
View Answer

Answer: a
Explanation: This statement will create an array and retrieve the first element of an array.
Output:
E

10. What is the output of the given statement?

span class="sy0"> * (Setf part-bins (make-array '(4)))
* (setf (aref part-bins 0) 'nails);
span class="sy0"> * (setf (aref part-bins 1) 'nuts);
span class="sy0"> * (setf (aref part-bins 2) 'bolts)
* (setf (aref part-bins 3) 'bike)
* (aref part-bins 2)
* (setf (aref part-bins 4) 'car)

a) Nails
b) Nuts
c) 2
d) Error
View Answer

Answer: d
Explanation: Error will be arised because of the last statement and it is out of bound.

Sanfoundry Global Education & Learning Series – LISP Programming Language.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

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
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.