Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C, C++, and Python Quiz

Total questions: 25

Worksheet time: 13mins

Name
Class
Date
1.

What is the default value of a local variable in C?

a)

0

b)

1

c)

Garbage Value

d)

Null

2.

Which operator is used to find the address of a variable?

a)

*

b)

&

c)

%

d)

@

3.

What will `printf("%d", sizeof(char));` output on most systems?

a)

1

b)

2

c)

4

d)

8

4.

Which function is used to deallocate memory in C?

a)

remove()

b)

delete()

c)

free()

d)

malloc()

5.

What is the result of `5 / 2` in C (using integer types)?

a)

2.5

b)

2

c)

3

d)

Error

6.

Which keyword is used to prevent a variable from being modified?

a)

static

b)

volatile

c)

immutable

d)

const

7.

A pointer that is not initialized to any specific memory address is called:

a)

Null Pointer

b)

Void Pointer

c)

Wild Pointer

d)

Dangling Pointer

8.

Which of the following is used for input in C++?

a)

cin

b)

cout

c)

scanf

d)

print

9.

What is the process of defining two or more functions with the same name but different parameters?

a)

Function Overriding

b)

Function Overloading

c)

Encapsulation

d)

Abstraction

10.

Which pillar of OOPS is used to hide the internal implementation details?

a)

Inheritance

b)

Polymorphism

c)

Abstraction

d)

Reusability

11.

What is a "Constructor" in C++?

a)

A function to delete an object

b)

A function called when an object is created

c)

A keyword to define a class

d)

A type of loop

12.

Which access specifier makes class members accessible only within the same class?

a)

public

b)

protected

c)

private

d)

internal

13.

In C++, `std::` is a:

a)

Variable

b)

Function

c)

Class

d)

Namespace

14.

What does the `new` operator do in C++?

a)

Creates a new variable

b)

Allocates memory on the Heap

c)

Allocates memory on the Stack

d)

Declares a constant

15.

Which of the following is the correct extension for Python files?

a)

.pt

b)

.py

c)

.python

d)

.pc

16.

How do you define a block of code in Python?

a)

Brackets { }

b)

Parentheses ( )

c)

Indentation

d)

Quotation marks

17.

What is the output of `print(type([]))`?

a)
b)
c)
d)
18.

Which keyword is used to create a function in Python?

a)

function

b)

define

c)

def

d)

func

19.

What will `print("abc" * 3)` output?

a)

abc3

b)

abcabcabc

c)

Error

d)

aabbcc

20.

Which data structure in Python is immutable?

a)

List

b)

Dictionary

c)

Tuple

d)

Set

21.

What is the correct way to handle exceptions in Python?

a)

try...catch

b)

try...except

c)

throw...catch

d)

if...error

22.

Which of these is a valid variable name in most languages?

a)

2nd_value

b)

total-amount

c)

_count

d)

class

23.

A loop that never ends is called an:

a)

Infinite loop

b)

Recursive loop

c)

While loop

d)

Fruitless loop

24.

In the ASCII table, which value usually represents the character 'A'?

a)

97

b)

65

c)

48

d)

1

25.

What is the time complexity of searching an element in a balanced Binary Search Tree?

a)

O(n)

b)

O(1)

c)

O(log n)

d)

O(n²)