wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Computer Science Quiz

Total questions: 20

Worksheet time: 13mins

Name
Class
Date
1.

What is the output of the following C code snippet?

4 lines
2.

Which of the following algorithms is used to find the shortest path in a weighted graph?

a)

Breadth-First Search (BFS)

b)

Depth-First Search (DFS)

c)

Dijkstra's Algorithm

d)

Kruskal's Algorithm

3.

Which of the following sorting algorithms has the best average-case performance for large datasets?

a)

Quick Sort

b)

Merge Sort

c)

Bubble Sort

d)

Insertion Sort

4.

Which data structure is used in implementing recursion?

a)

Stack

b)

Queue

c)

Linked List

d)

Tree

5.

Which of the following is not a component of a CPU?

a)

Arithmetic Logic Unit (ALU)

b)

Control Unit (CU)

c)

Memory Unit

d)

Register

6.

Which of the following is true about the IP protocol?

a)

It is connection-oriented

b)

It guarantees data delivery

c)

It is reliable

d)

It is a best-effort delivery service

7.

In which of the following scenarios is a hash table most efficient?

a)

When searching for an element

b)

When elements need to be sorted

c)

When inserting elements in a specific order

d)

When elements need to be traversed in order

8.

What is the main advantage of using a linked list over an array?

a)

Constant time access to elements

b)

Dynamic size and ease of insertion/deletion

c)

Better cache performance

d)

Fixed size

9.

What does a foreign key in a relational database do?

a)

Ensures that each value in a column is unique

b)

Establishes a link between the data in two tables

c)

Provides a default value for a column

d)

Ensures that each value in a column is not null

10.

Which SQL clause is used to filter records based on a specified condition?

a)

SELECT

b)

WHERE

c)

FROM

d)

JOIN

11.

Which of the following best describes polymorphism in object-oriented programming?

a)

Encapsulation of data

b)

Ability to inherit methods and properties from a parent class

c)

The ability of different classes to respond to the same function call

d)

None of the above

12.

Which of the following is a disadvantage of the Waterfall model in software development?

a)

Clear milestones

b)

Flexibility to change requirements

c)

Easy to manage

d)

Well-suited for large projects

13.

In computer networks, what is the main function of the transport layer?

a)

Routing of data packets

b)

Error detection and correction

c)

Flow control and reliability

d)

Physical transmission of data

14.

What is the time complexity of inserting an element in a Binary Search Tree (BST) in the worst case?

a)

O(1)

b)

O(log n)

c)

O(n)

d)

O(n log n)

15.

What is the purpose of the 'volatile' keyword in C/C++?

a)

To prevent a variable from being modified

b)

To indicate that a variable can be modified in ways not anticipated by the compiler

c)

To specify a default value for a variable

d)

To ensure that a variable is initialized before use

16.

In operating systems, what is thrashing?

a)

When the CPU is idle

b)

When a process is terminated abruptly

c)

Excessive swapping of pages between main memory and disk

d)

When a system runs out of memory

17.

In relational databases, what does the ACID acronym stand for?

a)

Addition, Consistency, Isolation, Durability

b)

Atomicity, Consistency, Isolation, Durability

c)

Atomicity, Consistency, Information, Durability

d)

Addition, Consistency, Information, Durability

18.

Which of the following is a characteristic of a B-tree?

a)

All leaf nodes are at the same level

b)

It is a binary tree

c)

Nodes have at most two children

d)

All nodes contain the same number of keys

19.

Which of the following statements about machine learning is true?

a)

Supervised learning requires labeled data

b)

Unsupervised learning requires labeled data

c)

Reinforcement learning does not involve a reward system

d)

All of the above

20.

What is a lambda expression in programming?

a)

A function with no parameters

b)

An anonymous function

c)

A function that always returns an integer

d)

A function that never terminates