CS210 Programming Languages
Midterm Exam Review (Qns & Ans)
2025
1. Which programming paradigm focuses on dividing a program
into reusable procedures or functions?
A. Object-oriented programming
B. Procedural programming
C. Declarative programming
D. Functional programming
ANS: B. Procedural programming
Rationale: Procedural programming emphasizes breaking tasks
into procedures or functions, making code modular and reusable.
2. Which programming language is most commonly associated
with web development on both the client-side and server-side?
©2025
, A. Python
B. JavaScript
C. C++
D. Ruby
ANS: B. JavaScript
Rationale: JavaScript is widely used for web development,
powering dynamic interactions on both the client and server sides.
3. What is the main purpose of garbage collection in
programming languages?
A. Managing file input/output operations
B. Removing unused variables and freeing memory space
C. Debugging runtime errors in code
D. Allocating memory for declared variables
ANS: B. Removing unused variables and freeing memory
space
Rationale: Garbage collection automatically deallocates
memory no longer in use, preventing memory leaks.
4. Which programming language introduced the concept of
object-oriented programming?
A. Java
©2025
, B. Smalltalk
C. Python
D. C++
ANS: B. Smalltalk
Rationale: Smalltalk pioneered the principles of object-
oriented programming, including encapsulation and
polymorphism.
5. What is a key feature of statically typed programming
languages?
A. Types are checked during runtime
B. Variables must have their types explicitly declared before use
C. The language is focused on dynamic scoping
D. Variables can hold different data types during execution
ANS: B. Variables must have their types explicitly declared
before use
Rationale: Statically typed languages, like Java and C++,
require explicit type declarations at compile time.
---
Fill-in-the-Blank Questions
©2025
, 6. In programming languages, ________ is a sequence of
instructions written to perform a specific task.
ANS: Algorithm
Rationale: An algorithm defines a structured approach to
solving computational problems.
7. The ________ keyword is used in Python to define a function.
ANS: def
Rationale: The `def` keyword in Python allows programmers
to create user-defined functions.
8. In programming, ________ refers to embedding one control
structure within another, such as a loop inside a loop.
ANS: Nesting
Rationale: Nesting is a technique used to handle hierarchical or
complex scenarios within code.
9. In Java, the ________ access modifier allows class members
to be accessible by any other class in the same package.
ANS: default
Rationale: The default access modifier in Java enables
package-level visibility without explicitly declaring it.
©2025
Midterm Exam Review (Qns & Ans)
2025
1. Which programming paradigm focuses on dividing a program
into reusable procedures or functions?
A. Object-oriented programming
B. Procedural programming
C. Declarative programming
D. Functional programming
ANS: B. Procedural programming
Rationale: Procedural programming emphasizes breaking tasks
into procedures or functions, making code modular and reusable.
2. Which programming language is most commonly associated
with web development on both the client-side and server-side?
©2025
, A. Python
B. JavaScript
C. C++
D. Ruby
ANS: B. JavaScript
Rationale: JavaScript is widely used for web development,
powering dynamic interactions on both the client and server sides.
3. What is the main purpose of garbage collection in
programming languages?
A. Managing file input/output operations
B. Removing unused variables and freeing memory space
C. Debugging runtime errors in code
D. Allocating memory for declared variables
ANS: B. Removing unused variables and freeing memory
space
Rationale: Garbage collection automatically deallocates
memory no longer in use, preventing memory leaks.
4. Which programming language introduced the concept of
object-oriented programming?
A. Java
©2025
, B. Smalltalk
C. Python
D. C++
ANS: B. Smalltalk
Rationale: Smalltalk pioneered the principles of object-
oriented programming, including encapsulation and
polymorphism.
5. What is a key feature of statically typed programming
languages?
A. Types are checked during runtime
B. Variables must have their types explicitly declared before use
C. The language is focused on dynamic scoping
D. Variables can hold different data types during execution
ANS: B. Variables must have their types explicitly declared
before use
Rationale: Statically typed languages, like Java and C++,
require explicit type declarations at compile time.
---
Fill-in-the-Blank Questions
©2025
, 6. In programming languages, ________ is a sequence of
instructions written to perform a specific task.
ANS: Algorithm
Rationale: An algorithm defines a structured approach to
solving computational problems.
7. The ________ keyword is used in Python to define a function.
ANS: def
Rationale: The `def` keyword in Python allows programmers
to create user-defined functions.
8. In programming, ________ refers to embedding one control
structure within another, such as a loop inside a loop.
ANS: Nesting
Rationale: Nesting is a technique used to handle hierarchical or
complex scenarios within code.
9. In Java, the ________ access modifier allows class members
to be accessible by any other class in the same package.
ANS: default
Rationale: The default access modifier in Java enables
package-level visibility without explicitly declaring it.
©2025