This set of LISP Multiple Choice Questions & Answers (MCQs) focuses on “Reading”.
1. Which primitive is used to connect the files with the streams?
a) Read
b) Format
c) With-open-file
d) None of the mentioned
View Answer
Explanation: Streams are created, variables are bound to them and they are connected to files using with-open-file.
2. How many types of streams are available in lisp?
a) 1
b) 2
c) 3
d) 4
View Answer
Explanation: There are two types of streams available in streams. They are input and output streams.
3. Which stream is involved with print and format forms?
a) Input
b) Output
c) Both Input & Output
d) None of the mentioned
View Answer
Explanation: Output streams are involved with print and format forms.
4. What will happen if nil is supplied as second argument in read form?
a) T
b) Value
c) Nil
d) None of the mentioned
View Answer
Explanation: In this case read will return NIL, instead of giving error.
5. How many types of read forms are available in file manipulation?
a) 1
b) 2
c) 3
d) 4
View Answer
Explanation: The two types of read forms available in read form are read-line and read-char.
6. What is the output of the given statement?
span class="sy0"> * (read)(+ 2 2) * (eval (read))(+ 2 2)
a) 2
b) 3
c) 4
d) Error
View Answer
Explanation: This statement will add up the given values and print out the result.
Output:
4
7. What is the output of the given statement?
* (length '(a b c)) * (reverse '(a b c))
a) 3
b) C B A
c) A B C
d) Both 3 & C B A
View Answer
Explanation: First statement will print the length and second statement will reverse the string.
Output:
3
(C B A)
8. What is the output of the given statement?
span class="sy0"> * (elt "stevejobs" 6)
a) o
b) e
c) #/o
d) None of the mentioned
View Answer
Explanation: This statement will print the index sixth letter of the given string.
Output:
#/o
9. What is the output of the given statement?
span class="sy0"> * (read-line)This is a test.
a) This is a test.
b) Nil
c) Error
d) Both This is a test. & Nil
View Answer
Explanation: This statement will read the given line and print it.
Output:
“This is a test.”
NIL
10. What is the output of the given statement?
span class="sy0"> * (search "boris" "katz, boris" :test #'char-equal)
a) Katz
b) Boris
c) 6
d) Error
View Answer
Explanation: This statement will search for the given string and print index of first letter that match.
Output:
6
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 Computer Science Books
- Practice Computer Science MCQs
- Check LISP Books
- Apply for Computer Science Internship