IS 122
Programming Logic
LATEST MIDTERMS REVIEW
Q&S
©2024/2025
,1. Multiple Choice: What is the output of the following Python
code snippet?
```python
list = ['a', 'b', 'c', 'd']
print("".join(list[::2]))
```
A) ac
B) bd
C) abc
D) None of the above
Correct Answer: A) ac
Rationale: The slicing `list[::2]` takes every second element from
the list starting from the first element. Therefore, it takes 'a' and
'c'.
2. Fill-in-the-Blank: An ________ search algorithm is more
efficient than a linear search algorithm for sorted lists.
Correct Answer: Binary
©2024/2025
, Rationale: A binary search algorithm divides the list in half each
time, which makes it more efficient for sorted lists compared to a
linear search that checks each element sequentially.
3. True/False: In object-oriented programming, encapsulation is
not useful for hiding the internal state of an object.
Correct Answer: False
Rationale: Encapsulation is a fundamental concept in object-
oriented programming that is used to hide the internal state of an
object and expose only necessary parts through an interface.
4. Multiple Response: Which of the following are principles of
Object-Oriented Programming?
A) Inheritance
B) Encapsulation
C) Polymorphism
D) Recursion
Correct Answers: A) Inheritance, B) Encapsulation, C)
Polymorphism
Rationale: Inheritance, encapsulation, and polymorphism are all
key principles of object-oriented programming. Recursion is a
programming technique, not a principle of OOP.
©2024/2025
Programming Logic
LATEST MIDTERMS REVIEW
Q&S
©2024/2025
,1. Multiple Choice: What is the output of the following Python
code snippet?
```python
list = ['a', 'b', 'c', 'd']
print("".join(list[::2]))
```
A) ac
B) bd
C) abc
D) None of the above
Correct Answer: A) ac
Rationale: The slicing `list[::2]` takes every second element from
the list starting from the first element. Therefore, it takes 'a' and
'c'.
2. Fill-in-the-Blank: An ________ search algorithm is more
efficient than a linear search algorithm for sorted lists.
Correct Answer: Binary
©2024/2025
, Rationale: A binary search algorithm divides the list in half each
time, which makes it more efficient for sorted lists compared to a
linear search that checks each element sequentially.
3. True/False: In object-oriented programming, encapsulation is
not useful for hiding the internal state of an object.
Correct Answer: False
Rationale: Encapsulation is a fundamental concept in object-
oriented programming that is used to hide the internal state of an
object and expose only necessary parts through an interface.
4. Multiple Response: Which of the following are principles of
Object-Oriented Programming?
A) Inheritance
B) Encapsulation
C) Polymorphism
D) Recursion
Correct Answers: A) Inheritance, B) Encapsulation, C)
Polymorphism
Rationale: Inheritance, encapsulation, and polymorphism are all
key principles of object-oriented programming. Recursion is a
programming technique, not a principle of OOP.
©2024/2025