wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Programming Concepts Worksheet

Total questions: 20

Worksheet time: 25mins

Name
Class
Date
1.

(C) What is the size of a pointer on a 64-bit system?

a)

2 bytes

b)

4 bytes

c)

8 bytes

d)

Depends on the data type it points to.

2.

(Python) What is the result of type(type)?

a)

<class 'object'>

b)

<class 'str'>

c)

<class 'type'>

d)

<class 'class'>

3.

What is the "Diamond Problem" related to?

a)

Memory Leak

b)

Encapsulation

c)

Multiple Inheritance

d)

Recursion

4.

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)

A. 2

b)

B. 3

c)

C. 4

d)

D. 5

5.

(C++) Which storage class specifier maintains a variable's value even after its scope has ended?

a)

static

b)

extern

c)

auto

d)

volatile

6.

(Python) What is the output of bool(0) or bool("False")?

a)

True

b)

False

c)

0

d)

Error

7.

(C++) What is a "Pure Virtual Function"?

a)

A function with no body, initialized to 0.

b)

A function in a private class.

c)

A static method.

8.

(C) What is the output of printf("%d", 1 << 31); on a 32-bit signed integer system?

a)

2312^{31}

b)

-2147483648

c)

1

d)

0

9.

In Python, how are arguments passed?

a)

Call by value

b)

Call by reference

c)

Call by object reference (assignment)

d)

Call by name

10.

(C++) When using virtual functions, what does the compiler usually add to the class objects?

a)

A. A reference to the parent class.

b)

B. A VTable Pointer (vptr).

c)

C. A copy of the function code.

d)

D. A static counter.

11.

(Python) Which describes a 'short-circuit' evaluation in a logical AND (&&) operation?

a)

The operation returns true if at least one operand is true.

b)

The first operand is ignored if the second operand is true.

c)

The second operand is only evaluated if the first operand is true.

d)

Both operands are evaluated regardless of their values.

12.

(Python) In the dictionary comprehension {x: x**2 for x in range(3)}, what is the output?

a)

{0: 0, 1: 1, 2: 4}

b)

{1: 1, 2: 4, 3: 9}

c)

{0, 1, 4}

d)

[0, 1, 4]

13.

(C++ / Python) Which is true about a "Friend Function"?

a)

It is a member function of the class.

b)

It can access private and protected members of the class.

14.

(C) A program compiles without errors but crashes when accessing dynamically allocated memory. Which error is most likely?

a)

Syntax error

b)

Logical error

c)

Dangling pointer

d)

Preprocessor error

15.

(Python) What happens when you execute x = (1, 2, [3, 4]) and then x[2].append(5)?

a)

TypeError (Tuple is immutable)

b)

x becomes (1, 2, [3, 4, 5])

c)

x becomes (1, 2, [3, 4], 5)

d)

The list is copied to a new memory address.

16.

(C++) A class should not allow object creation but must allow derived classes to define behavior. What must be included?

a)

Static function

b)

Private destructor

c)

Pure virtual function

d)

Inline constructor

17.

(C) What is the output of int a=10, *p=&a; printf("%d", +*p);?

a)

A. 10

b)

B. 11

c)

C. 12

d)

D. Address of a

18.

A function calls itself with a modified argument until an 'exit condition' is met. What is the term for this condition?

a)

Base Case

b)

Iteration Limit

c)

Break Point

d)

Recursive Step

19.

(C++) What is a "virtual function"?

a)

A function that doesn't exit.

b)

A function redefined in a derived class.

c)

A static function.

20.

(Python) If you try to update the value of an element in a tuple, what happens?

a)

A. A new tuple is created with the updated value.

b)

B. The change is saved successfully.

c)

C. The tuple is automatically converted to a list.

d)

D. It raises a TypeError.