Modern Programming Languages MCQs with Answers
Practice important Modern Programming Languages MCQs with answers and explanations.
Chapter: 20
Q361:
Which statement is used in LISP for conditional control?
A. while
B. if
C. when
D. for
Correct Answer:
B
Chapter: 20
Q362:
LISP functions return the value of the ______ in their body.
A. First expression
B. Last expression
C. Middle expression
D. All expressions
Correct Answer:
B
Chapter: 20
Q363:
The syntax (if <test> <then> <else>) is used for ______ in LISP.
A. Looping
B. Conditional branching
C. List creation
D. Recursion
Correct Answer:
B
Chapter: 20
Q364:
What is the output of (power 2 3) using the recursive function?
A. 6
B. 8
C. 4
D. 16
Correct Answer:
B
Chapter: 20
Q365:
What is the base case in the recursive member function?
A. List is empty
B. List has one element
C. x is not in list
D. None of these
Correct Answer:
A
Chapter: 20
Q366:
What will the function (length '(a b c)) return in LISP?
A. 3
B. 4
D. Error
Correct Answer:
A
Chapter: 20
Q367:
In LISP, recursion is primarily used for ______.
A. List operations
B. Iteration
C. Boolean operations
D. Mathematical operations
Correct Answer:
B
Chapter: 20
Q368:
What does (cond (t 'default)) always return in LISP?
A. NIL
B. Error
C. The default value
D. True value
Correct Answer:
C
Chapter: 20
Q369:
The power function (defun power (x y) ...) computes ______.
A. Factorial
B. Exponentiation
C. Square root
D. Logarithm
Correct Answer:
B
Chapter: 20
Q370:
What will (if (= 1 1) 'true 'false) return in LISP?
A. NIL
B. 1
D. Error
Correct Answer:
B
Chapter: 20
Q371:
What does the member function return if the symbol is not found?
A. NIL
B. The original list
C. Error
D. NULL
Correct Answer:
A
Chapter: 20
Q372:
Which LISP function computes the intersection of two lists?
A. member
B. cond
C. intersection
D. union
Correct Answer:
C
Chapter: 20
Q373:
Which clause is required in a cond statement to act as default?
A. eq
B. NIL
C. T
D. None
Correct Answer:
C
Chapter: 20
Q374:
Recursion in LISP stops when ______ is met.
A. Global variable is set
B. A base case is met
C. The function fails
D. A default case is called
Correct Answer:
B
Chapter: 20
Q375:
Fill in the blank: The syntax for defining a function in LISP is (defun func-name (args) ______ ).
A. Function body
B. Parameters
C. Variables
D. Return value
Correct Answer:
A
Chapter: 20
Q376:
What is the output of (intersection '(a b c) '(b c d))?
A. (a b)
B. (b c)
C. (c d)
D. (a c)
Correct Answer:
B
Chapter: 21
Q377:
What does the intersection function in LISP return?
A. Common elements of two lists
B. A unique union of two lists
C. All elements from the first list
D. A reversed list
Correct Answer:
A
Chapter: 21
Q378:
In LISP, what does the set-difference function compute?
A. Common elements of two lists
B. Difference of two sets
C. Total number of elements
D. Intersection of two sets
Correct Answer:
B
Chapter: 21
Q379:
What is the purpose of the dotimes function in LISP?
A. Execute a loop for a fixed number of times
B. Find duplicates in a list
C. Compute a recursive function
D. Count list elements dynamically
Correct Answer:
A
Chapter: 21
Q380:
In the dolist function, what does the variable x represent?
A. Index of an element
B. An element of the list
C. The length of the list
D. The result of the loop
Correct Answer:
B