• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 3 out of 18 pages
Exam (elaborations)

ASU CSE 240 Introduction to Programming Languages Practice Exam

Document preview thumbnail
Preview 3 out of 18 pages

This document contains 60 multiple-choice practice questions with correct answers and rationales for ASU CSE 240 Introduction to Programming Languages. It covers Racket functional programming, Prolog logic programming, C and C++ programming, pointers and memory management, recursion, programming paradigms, language syntax and semantics, type systems, and object-oriented programming. The material provides explanations for each correct answer, making it useful for exam preparation, self-assessment, and reviewing key programming language concepts.

Content preview

ASU CSE 240 Introduction to Programming Languages
Practice Exam

1. What does (car '(1 2 3)) return in Racket?
A. '(1 2 3)
B. '(2 3)
C. 1
D. 3
Correct Answer: C. 1
Rationale: car returns the first element of a non-empty list.

2. What does (cdr '(1 2 3)) return?
A. '(1)
B. '(2 3)
C. 1
D. 3
Correct Answer: B. '(2 3)
Rationale: cdr returns the list without its first element.

3. What does (cons '(1) '(2)) return?
A. '(1 (2))
B. '((1 2))
C. '(1 2)
D. '((1) 2)
Correct Answer: D. '((1) 2)
Rationale: cons adds its first argument as a single new element at the front of the
second list, so the list (1) becomes the first element.

,4. What is the result of (map (lambda (x) (* x x)) '(1 2 3))?
A. '(1 4 9)
B. '(2 4 6)
C. '(1 2 3)
D. 14
Correct Answer: A. '(1 4 9)
Rationale: map applies the function to each element and returns a new list of the
results.

5. What does (filter odd? '(1 2 3 4 5)) return?
A. '(1 2 3 4 5)
B. 9
C. '(2 4)
D. '(1 3 5)
Correct Answer: D. '(1 3 5)
Rationale: filter keeps only the elements for which the predicate returns true.

6. What does (foldl cons '() '(1 2 3)) return?
A. '(1 2 3)
B. '()
C. '(3 2 1)
D. '(1 (2 (3)))
Correct Answer: C. '(3 2 1)
Rationale: foldl processes left to right: (cons 1 '()) gives (1), then (cons 2 '(1)) gives
(2 1), then (3 2 1).

7. What value does (let* ([x 2] [y (+ x 1)]) y) return?
A. 3
B. 2
C. 1
D. An error because x is undefined in y
Correct Answer: A. 3
Rationale: let* binds sequentially, so y can use the value of x defined just before it.

, 8. Given (define (f n) (if (= n 0) 0 (+ n (f (- n 1))))), what is (f
4)?
A. 0
B. 10
C. 24
D. 4
Correct Answer: B. 10
Rationale: f(4) = 4 + 3 + 2 + 1 + 0 = 10.

9. Which statement best describes a tail-recursive function?
A. It uses a loop internally
B. The recursive call is the last operation performed, so no work remains after it
returns
C. It calls itself twice
D. It never has a base case
Correct Answer: B. The recursive call is the last operation performed, so no
work remains after it returns
Rationale: Tail calls allow the implementation to reuse the stack frame, avoiding
stack growth.

10. What does ((lambda (x y) (+ x y)) 3 4) evaluate to?
A. A function
B. An error
C. '(3 4)
D. 7
Correct Answer: D. 7
Rationale: The anonymous function is applied immediately to 3 and 4, returning 7.

Document information

Uploaded on
October 12, 2026
Number of pages
18
Written in
2026/2027
Type
Exam (elaborations)
Contains
Questions & answers
$13.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Hosmerit
4.7
(261)
Sold
434
Followers
46
Items
4707
Last sold
1 hour ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions