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 in C
IV. Object-Oriented Programming in C++
V. Functional Programming in Scheme
VI. Logic Programming in Prolog
VII. Recursion and Control Structures
VIII. Data Structures and Memory Management
,2|Page
question 1: What is a programming paradigm?
Correct Answer: A fundamental style or approach to programming that influences how
programs are structured and executed.
Programming paradigms provide different ways of thinking about computation, such as
imperative, object-oriented, functional, and logic programming. Each paradigm has its own
strengths and is suited to different problem domains. Understanding paradigms helps
programmers choose the right tool for a given task.
question 2: What is the primary difference between declarative and imperative programming?
Correct Answer: Declarative programming specifies what the result should be, while
imperative programming specifies how to compute the result step by step.
Imperative programming uses statements that change program state, reflecting the von
Neumann architecture. Declarative programming focuses on desired outcomes and relies on
underlying engines to determine execution details. Functional and logic programming are
examples of declarative paradigms.
question 3: What is the von Neumann architecture's influence on imperative programming?
Correct Answer: It led to the model of sequential instruction execution and mutable
memory, which is central to imperative languages.
The von Neumann architecture stores both program instructions and data in memory and
executes instructions sequentially. Imperative languages like C directly reflect this model
through variables, assignment, and control flow. This makes imperative programs efficient
but can also introduce side effects.
question 4: What is the difference between compilation and interpretation?
Correct Answer: Compilation translates the entire source program into machine code
before execution, while interpretation executes the source program directly, statement
by statement.
Compiled programs generally run faster because translation occurs ahead of time.
Interpreted programs offer better debugging and portability but are often slower. Some
languages use hybrid approaches, translating to intermediate bytecode that is then
interpreted or just-in-time compiled.
, 3|Page
question 5: What is a hybrid implementation?
Correct Answer: A language implementation that combines compilation and
interpretation, often by compiling to an intermediate representation.
Java is a classic example: source code is compiled to bytecode, which is then interpreted or
just-in-time compiled by the Java Virtual Machine. This approach balances portability and
performance. Hybrid systems are common in modern language runtimes.
question 6: What is the difference between syntax and semantics?
Correct Answer: Syntax refers to the form and structure of valid programs, while
semantics refers to the meaning or behavior of those programs.
Syntax defines which strings are legal in a language, such as matching parentheses and
correct keyword usage. Semantics defines what those syntactically valid programs do when
executed. A program can be syntactically correct but semantically wrong.
question 7: What is lexical analysis?
Correct Answer: The phase of compilation that converts a stream of characters into a
stream of tokens.
Lexical analysis, or scanning, identifies keywords, identifiers, operators, and literals. It
removes whitespace and comments. The resulting tokens are passed to the parser for
syntactic analysis.
question 8: What is parsing?
Correct Answer: The phase of compilation that analyzes the token stream according to
the language's grammar to build a parse tree or syntax tree.
Parsing checks whether the tokens form valid syntactic structures. It uses a grammar, often
expressed in BNF or EBNF. The parse tree represents the hierarchical structure of the
program.
question 9: What is orthogonality in language design?
Correct Answer: The principle that a small set of primitive constructs can be combined
in a small number of ways to build the language's control and data structures.