250+ TOP MCQs on Array and Answers

LISP Multiple Choice Questions on “Array”.

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

Answer: c
Clarification: An array is a data type in which expressions are stored in places entified 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

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

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

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

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

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

  250+ TOP MCQs on Structures and Answers

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

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

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

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

Leave a Comment

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

Scroll to Top