This set of LISP Questions and Answers for Freshers focuses on “S-Expression – 2”.
1. If S1, S2, S3… are S-expressions then list: (S1 S2 S3 ….) is a/an ____
b) Error will occur
Explanation: According to recursive definition of S-expression if S1, S2, S3… are S-expressions then list: (S1 S2 S3 ….) is also an S-expression. S-expression is short form of symbolic expressions.
2. What are examples of some of the atoms?
a) Numeric, Integer, Ratio
b) Numeric, Lists
d) Cons of two atoms
Explanation: Atoms consist of Literals, Numbers, Integers, Ratios, Flonum. Lists are formed from atoms. Cons of two atoms is referred to as List.
3. Which of the following can be considered as List?
Explanation: An empty thing is also considered as List. Empty thing means the braces () with no arguments. Numbers are not counted in Lists.
4. Is LISP a case sensitive language.
Explanation: LISP is not a case sensitive language. Example: (print ‘a) will behave same as (PRINT ‘A).
5. What is the output of the following LISP statement?
Explanation: In LISP primitive programming language, write is a keyword that is used to print things on the output terminal of the compiler.
6. What is the use of (WRITE ‘Argument)?
a) It converts argument in small letters to capital letters
b) It returns capital letters from the string
c) Same as (write ‘argument)
d) It converts the string into alphabetical order/sequence
Explanation: It works same as (write ‘argument) because LISP is case insensitive language.
7. What is the output of the following LISP statement?
(write '(a b c d))
a) A B C D
d) B C D
Explanation: With use of write primitive, we can write space separated words with the use of braces.
Output: A B C D
8. What is the output of the following LISP statement?
b) ‘ is not used so error occurs
d) No output
Explanation: It will print number 1. If we use ‘1 then that will not be a number. ‘1 will convert number 1 to a list and it will have properties of list and not numbers.
9. What is the output of the following LISP statement?
a) Ascii value of + divides by that of _
d) + only
Explanation: It will not print division of ASCII values of + and _. Write will print arguments as it is in the output.
10. What is the output of the following LISP statement?
c) ASCII value of #
d) # will be printed without using ‘
Explanation: Compiler error will occur after the execution of this statement.
Output: Compiler error: “objects printed as # in view of *PRINT-LEVEL* cannot be read back in”.
Sanfoundry Global Education & Learning Series – LISP Programming Language.
To practice all areas of LISP for Freshers, here is complete set of 250+ Multiple Choice Questions and Answers on LISP Programming Language.