LISP Multiple Choice Questions on “S-Expression”.
1. What S-expression consists of?
a) Atoms and Lists
b) Numeric only
c) Literals only
d) Atoms only
Answer: a
Clarification: S-expression consists of both Atoms and Lists. It also consists of numeric and literals.
2. All program statements and data in LISP are represented by S-expressions?
a) True
b) False
Answer: a
Clarification: Yes, all the program statements and data are represented by S-expressions in LISP. S-expressions or symbolic expressions are the syntactic elements of the LISP programming language.
3. What are the basic building blocks of S-expressions?
a) Atoms
b) Lists
c) Numbers
d) Predicates
Answer: a
Clarification: Atoms are building blocks of S-expressions. Even atoms are consered as a fundamental unit of LISP.
4. If X and Y are S-expression then (X.Y) is a/an ____
a) S-expression
b) Atom
c) List
d) Predicate
Answer: a
Clarification: In LISP programming if X and Y are S-expressions then the dotted pair (X.Y) is also consered as S-expression.
5. Atoms are consered as S-expressions.
a) True
b) False
Answer: a
Clarification: Atoms are also consered as S-expressions. Rather S-expressions are formed from atoms.
6. What will be the output of the following LISP statement?
a) FIRST-STATEMENT
b) FIRST
c) STATEMENT
d) –
Answer: a
Clarification: Print will output the argument given to it as it is on the output terminal of the compiler.
Output: FIRST-STATEMENT
7. What will be the output of the following LISP statement?
a) ATOM
b) A
c) TOM
d) ATOM infinitely
Answer: a
Clarification: Print is used to write the argument proved to it on the output part of the program.
Output: ATOM
8. What will be the output of the following LISP statement?
a) LIST-ATOM
b) LIST
c) ATOM
d) –
Answer: a
Clarification: Print primitive does not give an error if the argument has -(hyphen). It prints on output the argument proved to it.
Output: LIST-ATOM
9. What is the output of the following LISP statement?
a) LIST ATOM
b) LIST
c) ATOM
d) Error
Answer: d
Clarification: We cannot give space in print’s argument in this type of declaration. It will conser that two arguments are given to print primitive one being list and other is an atom. But we can give only one argument to print so it will give error.
10. What is the output of the following LISP statement?
a) LIST ATOM
b) LIST
c) ATOM
d) Error
Answer: a
Clarification: If we keep the space separated items in the braces then the print will not give error. The list and atom are two different words but they are bound in one single argument by use of braces.
Output: LIST ATOM.
