NEW
Font size
WorksheetsProgramming Concepts Worksheet
Total questions: 20
Worksheet time: 25mins
(C) What is the size of a pointer on a 64-bit system?
2 bytes
4 bytes
8 bytes
Depends on the data type it points to.
(Python) What is the result of type(type)?
<class 'object'>
<class 'str'>
<class 'type'>
<class 'class'>
What is the "Diamond Problem" related to?
Memory Leak
Encapsulation
Multiple Inheritance
Recursion
A loop starts at 1, continues while the counter is less than or equal to 5, and increments by 2 each time. How many times does it execute?
A. 2
B. 3
C. 4
D. 5
(C++) Which storage class specifier maintains a variable's value even after its scope has ended?
static
extern
auto
volatile
(Python) What is the output of bool(0) or bool("False")?
True
False
0
Error
(C++) What is a "Pure Virtual Function"?
A function with no body, initialized to 0.
A function in a private class.
A static method.
(C) What is the output of printf("%d", 1 << 31); on a 32-bit signed integer system?
231
-2147483648
1
0
In Python, how are arguments passed?
Call by value
Call by reference
Call by object reference (assignment)
Call by name
(C++) When using virtual functions, what does the compiler usually add to the class objects?
A. A reference to the parent class.
B. A VTable Pointer (vptr).
C. A copy of the function code.
D. A static counter.
(Python) Which describes a 'short-circuit' evaluation in a logical AND (&&) operation?
The operation returns true if at least one operand is true.
The first operand is ignored if the second operand is true.
The second operand is only evaluated if the first operand is true.
Both operands are evaluated regardless of their values.
(Python) In the dictionary comprehension {x: x**2 for x in range(3)}, what is the output?
{0: 0, 1: 1, 2: 4}
{1: 1, 2: 4, 3: 9}
{0, 1, 4}
[0, 1, 4]
(C++ / Python) Which is true about a "Friend Function"?
It is a member function of the class.
It can access private and protected members of the class.
(C) A program compiles without errors but crashes when accessing dynamically allocated memory. Which error is most likely?
Syntax error
Logical error
Dangling pointer
Preprocessor error
(Python) What happens when you execute x = (1, 2, [3, 4]) and then x[2].append(5)?
TypeError (Tuple is immutable)
x becomes (1, 2, [3, 4, 5])
x becomes (1, 2, [3, 4], 5)
The list is copied to a new memory address.
(C++) A class should not allow object creation but must allow derived classes to define behavior. What must be included?
Static function
Private destructor
Pure virtual function
Inline constructor
(C) What is the output of int a=10, *p=&a; printf("%d", +*p);?
A. 10
B. 11
C. 12
D. Address of a
A function calls itself with a modified argument until an 'exit condition' is met. What is the term for this condition?
Base Case
Iteration Limit
Break Point
Recursive Step
(C++) What is a "virtual function"?
A function that doesn't exit.
A function redefined in a derived class.
A static function.
(Python) If you try to update the value of an element in a tuple, what happens?
A. A new tuple is created with the updated value.
B. The change is saved successfully.
C. The tuple is automatically converted to a list.
D. It raises a TypeError.
