• ¿Documento equivocado? Cámbialo gratis
  • Escrito por estudiantes que aprobaron
  • Inmediatamente disponible después del pago
  • Leer en línea o como PDF
Vender
¿Dónde estudias?
Tu idioma
Document preview thumbnail
Vista previa 4 fuera de 50 páginas
Examen

Asu Cse 240 Introduction To Programming Languages Midterm Examination: Study Guide | Latest Update 2026/2027 | Practice Questions And Answers | Exam Review

Document preview thumbnail
Vista previa 4 fuera de 50 páginas

This comprehensive examination preparation document is designed for candidates preparing for the CSE 240 Introduction to Programming Languages midterm examination at Arizona State University. The examination assesses mastery of the fundamental concepts of programming paradigms, including procedural (C/C++), object-oriented (C++), functional (Scheme/LISP), and logic (Prolog) programming. Questions are calibrated to the rigor of the 2026 CSE 240 midterm blueprint, emphasizing syntax, semantics, type systems, control structures, recursion, memory management, and paradigm-specific problem-solving. Candidates will encounter scenarios drawn from real-world programming environments, including code analysis, output prediction, error identification, and conceptual understanding of language design principles. The content reflects the most current course objectives, including strong versus weak typing, compilation versus interpretation, and the relationship between programming paradigms and hardware execution.

Vista previa del contenido

Page 1 of 50




ASU CSE 240 INTRODUCTION TO
PROGRAMMING LANGUAGES MIDTERM
EXAMINATION: STUDY GUIDE | LATEST
UPDATE 2026/2027 | PRACTICE QUESTIONS
AND ANSWERS | EXAM REVIEW




TABLE OF CONTENTS

I. Programming Language Fundamentals and Paradigms
II. Syntax, Semantics, and Language Translation
III. Procedural Programming (C)
IV. Object-Oriented Programming (C++)
V. Functional Programming (Scheme/LISP)
VI. Logic Programming (Prolog)
VII. Data Structures and Memory Management
VIII. Recursion and Control Structures

, Page 2 of 50

question 1: What is the primary characteristic that distinguishes the imperative programming
paradigm from the functional programming paradigm?

Correct Answer: Imperative programming focuses on how to achieve a result through
step-by-step instructions, while functional programming focuses on what result is
desired through expression evaluation.

The imperative paradigm emphasizes explicit sequences of commands that modify program
state, reflecting the von Neumann architecture. The functional paradigm treats computation
as the evaluation of mathematical functions, avoiding mutable state and side effects. This
fundamental difference affects program structure, readability, and execution semantics.

question 2: In the context of programming language design, what does the term
"orthogonality" refer to?

Correct Answer: Orthogonality refers to the principle that a relatively small set of
primitive constructs can be combined in a relatively small number of ways to build the
control and data structures of a language.

Orthogonality means that features of a language are independent and do not interact in
unexpected ways. For example, if a language allows statements to be nested, any statement
should be nestable within any other. High orthogonality generally simplifies language
learning and use, but excessive orthogonality can lead to complexity.

question 3: What is the difference between a compiler and an interpreter in terms of program
execution?

Correct Answer: A compiler translates the entire source program into machine code
before execution, while an interpreter executes the source program directly, statement
by statement.

Compilation produces an executable file that can be run independently, offering faster
execution but requiring a separate translation step. Interpretation offers better debugging
information and portability but is generally slower. Some languages use hybrid approaches,
translating to intermediate code that is then interpreted.

question 4: In C, what is the difference between #define and const?

, Page 3 of 50

Correct Answer: #define creates a textual macro that is replaced by the preprocessor
before compilation, while const creates a typed, read-only variable that is handled by the
compiler.

#define is a preprocessor directive with no type checking and no scope rules, which can lead
to unexpected side effects if not used carefully. const provides type safety, scope, and can be
used with pointers and function parameters. Modern C programming favors const for
constants when possible.

question 5: What is the output of the following C code snippet? int x = 5; int y = 2; float z = x
/ y; printf("%f", z);

Correct Answer: 2.000000

In C, integer division is performed when both operands are integers, so evaluates to 2
(the fractional part is discarded). This integer result is then implicitly converted to float when
assigned to z. To obtain 2.5, at least one operand must be a floating-point type, such as
(float)x / y.

question 6: In C++, what is the purpose of a virtual function?

Correct Answer: A virtual function enables dynamic binding, allowing a derived class to
override a base class function and have the correct version called based on the actual
object type at runtime.

Virtual functions support polymorphism in C++. When a base class pointer or reference
points to a derived class object, calling a virtual function invokes the derived class's version.
Without virtual, the function called is determined by the pointer/reference type, not the object
type.

question 7: In Scheme, what is the result of evaluating (car '(1 2 3))?

Correct Answer: 1

The car function returns the first element of a list. In Scheme, '(1 2 3) is a quoted list, meaning
it is treated as data rather than a function call. Therefore, (car '(1 2 3)) returns the first
element, which is 1.

question 8: In Prolog, what is the difference between a fact and a rule?

, Page 4 of 50

Correct Answer: A fact is an unconditional statement that is always true, while a rule is
a conditional statement that is true if its conditions are met.

Facts are the basic assertions in a Prolog program, such as likes(mary, wine). Rules are
implications, such as happy(X) :- likes(X, wine)., which states that X is happy if X likes wine.
Prolog uses facts and rules to derive conclusions through queries and resolution.

question 9: What is tail recursion, and why is it important in functional programming?

Correct Answer: Tail recursion occurs when a recursive call is the last operation in a
function, allowing the compiler to optimize it into a loop and avoid stack overflow.

In tail recursion, no computation is pending after the recursive call returns. Scheme and
other functional languages require tail-call optimization, enabling efficient iteration through
recursion. Non-tail recursion consumes stack space proportional to the recursion depth,
which can cause stack overflow for large inputs.

question 10: What is the difference between strong typing and weak typing in programming
languages?

Correct Answer: Strong typing enforces strict type rules and prevents implicit type
conversions that could lead to errors, while weak typing allows implicit conversions
between unrelated types.

Strongly typed languages, such as Java and C#, catch type errors at compile time. Weakly
typed languages, such as JavaScript and C, allow operations between incompatible types,
potentially leading to runtime errors or unexpected behavior. The strength of typing is a
spectrum, and languages vary in their enforcement.

question 11: In C, what is the difference between malloc and calloc?

Correct Answer: malloc allocates a block of memory of a specified size and leaves it
uninitialized, while calloc allocates memory for an array of elements and initializes all
bytes to zero.

malloc takes a single argument specifying the total number of bytes to allocate. calloc takes
two arguments: the number of elements and the size of each element. Both return a void
pointer to the allocated memory, which must be cast to the appropriate type and freed with
free when no longer needed.

Información del documento

Subido en
30 de septiembre de 2026
Número de páginas
50
Escrito en
2026/2027
Tipo
Examen
Contiene
Preguntas y respuestas
$19.99

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Seller avatar
TopTier
4.0
(1)
Vendido
1
Seguidores
0
Artículos
640
Última venta
3 meses hace



Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes