LISP Questions & Answers – Reading

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

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

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

Answer: b
Explanation: Output streams are involved with print and format forms.
advertisement
advertisement

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

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

Answer: b
Explanation: The two types of read forms available in read form are read-line and read-char.
Note: Join free Sanfoundry classes at Telegram or Youtube

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

Answer: c
Explanation: This statement will add up the given values and print out the result.
Output:
4
advertisement

7. What is the output of the given statement?

advertisement
* (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

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

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

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

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

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.