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
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
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
Explanation: The array can be constructed and its dimension can be set by using make-array.
4. Which is present in the writer procedure for arrays?
a) Setf
b) Aref
c) Fref
d) Both Setf & Aref
View Answer
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
Explanation: Initial-Contents keyword along with the desired intial elements wrapped up in an array.
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
Explanation: This statement will create an array of elements and everything will be initialized to zero.
Output:
#(0 0 0 0)
7. What is the output of the given statement?
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
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
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
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
Explanation: Error will be arised because of the last statement and it is out of bound.
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.
- Check LISP Books
- Practice Computer Science MCQs
- Check Computer Science Books
- Apply for Computer Science Internship