LISP Interview Questions and Answers for Experienced people on “String Manipulation”.
1. Symbol manipulation in LISP is called as _____
a) atoms
b) lists
c) list processing
d) none of the mentioned
Answer: c
Clarification: Symbol manipulation in LISP is called as list processing. The full form of LISP is also List Processing.
2. Lists can be formed from ____
a) atoms
b) atoms and lists
c) lists
d) none of the mentioned
Answer: b
Clarification: Both atoms and lists can be used to form lists. Lists can be made from atoms. But atoms cannot be made from lists because atoms are the fundamental unit of LISP.
3. Which of the following are general-purpose dialects of LISP?
a) Clojure
b) Common LISP
c) Common LISP and Scheme
d) Clojure, Command LISP and Scheme
Answer: d
Clarification: The best-known general-purpose Lisp dialects are Clojure, Common Lisp, and Scheme.
4. What can be used to print “yes, no”?
a) (print “yes,no”)
b) (write “yes , no!”)
c) (print “yes,”)(print “,no”)
d) (print “yes”)(print “,”)(print “no”)
Answer: a
Clarification: (print “yes,no”) will print yes,no. Write has exclamation mark (!) in its argument so not correct. Multiple prints used will print their arguments in new line. So, the two times and three times used print will not print “yes,no” continuously, hence these options are wrong.
5. Can write-line keyword be used for printing strings?
a) True
b) False
Answer: a
Clarification: Write-line is also used to print the arguments. Other primitives used to print are print and write.
6. What will be the output of the following LISP statement?
a) “ABC”
b) ABC
c) ‘ABC
d) None of the mentioned
Answer: a
Clarification: “symbol-name” is used in symbol-manipulation. This primitive returns the argument proved to it in double quotes. So, here ABC was proved as argument and symbol-name return it as “ABC”.
Output: “ABC”
7. What will be the output of the following LISP statement?
a) |ABC|
b) ABC
c) “ABC”
d) None of the mentioned
Answer: b
Clarification: In LISP programming the || are consered as escape characters. The use of these escape characters will print ABC on the output terminal. But these escape characters return string without showing || in output only when all the characters are capital letters.
Output: ABC
8. What will be the output of the following LISP statement?
a) “better””better”
b) “better”
c) “better “better””
d) error will occur
Answer: a
Clarification: In this statement the two write primitive are nested. The inner write will prove “better” as argument to outer write. Hence, both writes will print their arguments in output.
Output: “better””better”
9. What will be the output of the following LISP statement?
a) “better””better”
b) “better”
c) error will occur
d) none of the mentioned
Answer: a
Clarification: In this statement the print primitive is nested in write. The print primitive will prove “better” as argument to write and give output “better””better”.
Output: “better””better”
10. What will be the output of the following LISP statement?
a) welcome
b) “welcome”
c) no output due to error
d) both welcome and “welcome” are possible
Answer: c
Clarification: The statement will show an error because “welcome” is kept in braces (). The use of braces will make the compiler to check if “welcome” is a symbol. But it is not a symbol so error will occur.
