wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

test1

Total questions: 28

Worksheet time: 18mins

Name
Class
Date
1.

What is the result?

SELECT COUNT(DISTINCT dept_id) FROM emp;

a)

A. Total employees

b)

B. Total departments

c)

C. Duplicate departments

d)

D. NULL

2.

Which data type stores large text?

a)

A. CHAR

b)

B. VARCHAR

c)

C. TEXT

d)

D. BOOLEAN

3.

What will this return?

SELECT * FROM emp WHERE salary != 50000;

a)

A. All salaries except 50000

b)

B. Only 50000

c)

C. Error

d)

D. NULL rows

4.

SELECT * FROM emp e LEFT JOIN dept d

ON e.dept_id = d.dept_id;

a)

A) Only matching rows

b)

B) All emp rows

c)

C) All dept rows

d)

D) Error

5.

DELETE FROM emp;

ROLLBACK;

a)

A) Data restored

b)

B) Data lost

c)

C) Error

d)

D) Partial restore

6.

Which statement is WRONG?

a)

A) DELETE can use WHERE clause

b)

B) TRUNCATE removes table structure

c)

C) DROP deletes table permanently

d)

D) DELETE can be rolled back

7.

Which statement is INCORRECT?

a)

A) AVG() ignores NULL values

b)

B) COUNT(column) counts NULL values

c)

C) SUM() ignores NULL values

d)

D) MAX() ignores NULL values

8.

To check NULL values in MySQL, we use:

a)

A) = NULL

b)

B) != NULL

c)

C) IS NULL

d)

D) == NULL

9.

SELECT * FROM emp ORDER BY salary;

a)

A) Sorted ascending

b)

B) Sorted descending

c)

C) Random order

d)

D) Error

10.

What is the effect of this query?

DELETE FROM emp WHERE dept_id IS NULL;

a)

A) Deletes all rows

b)

B) Deletes rows with NULL dept_id

c)

C) Deletes table

d)

D) Error

11.

Table emp has 100 rows.
10 rows have salary = NULL.

What is the result of:

SELECT COUNT(salary) FROM emp;

a)

A) 100

b)

B) 90

c)

C) 10

d)

D) NULL

12.

Table emp has salaries:
5000, 7000, NULL, 9000, NULL

SELECT AVG(salary) FROM emp;

a)

A) 7000

b)

B) 5250

c)

C) 6200

d)

D) NULL

13.

Table emp has salaries:
1000, 2000, 3000, 4000

SELECT MAX(salary) - MIN(salary) FROM emp;

a)

A) 3000

b)

B) 4000

c)

C) 1000

d)

D) Error

14.

Table emp has multiple departments.

SELECT dept_id FROM emp GROUP BY dept_id HAVING COUNT(*) = 1;

This returns:

a)

A) All departments

b)

B) Departments with single employee

c)

C) Departments with multiple employees

d)

D) Error

15.

SELECT DATEDIFF('2024-03-10','2024-03-01');

a)

A) 9

b)

B) 10

c)

C) -9

d)

D) Error

16.

SELECT *

FROM emp

WHERE salary > ANY (SELECT salary FROM emp WHERE dept_id = 10);

Returns:

a)

A) Employees earning more than all in dept 10

b)

B) Employees earning more than at least one in dept 10

c)

C) Employees of dept 10

d)

D) Error

17.

How many layers are there in the OSI model?

a)

A) 5

b)

B) 6

c)

C) 7

d)

D) 8

18.

Which layer of the OSI model is responsible for encryption and compression?

a)

A) Session

b)

B) Presentation

c)

C) Application

d)

D) Transport

19.

Which OSI layer provides end-to-end communication?

a)

A) Network

b)

B) Transport

c)

C) Session

d)

D) Data Link

20.

Which device operates at the Network layer?

a)

A) Hub

b)

B) Switch

c)

C) Router

d)

D) Repeater

21.

How many bits are there in an IPv4 address?

a)

A) 16

b)

B) 32

c)

C) 48

d)

D) 64

22.

Which IP address is used for loopback?

a)

A) 192.168.1.1

b)

B) 127.0.0.1

c)

C) 0.0.0.0

d)

D) 255.255.255.255

23.

Which transmission mode supports two-way simultaneous communication?

a)

A) Simplex

b)

B) Half-duplex

c)

C) Full-duplex

d)

D) Broadcast

24.

A = [2, 4, 6, 8]

sum = 0

FOR i = 0 TO length(A)-1

sum = sum + A[i]

END FOR

PRINT sum

a)

A) 12

b)

B) 14

c)

C) 18

d)

D) 20

25.

QUEUE Q

ENQUEUE(Q, 1)

ENQUEUE(Q, 2)

ENQUEUE(Q, 3)

DEQUEUE(Q)

PRINT FRONT(Q)

a)

A) 1

b)

B) 2

c)

C) 3

d)

D) Queue empty

26.

head → 10 → 20 → 30 → NULL

temp = head

count = 0

WHILE temp != NULL

count = count + 1

temp = temp.next

END WHILE

PRINT count

a)

A) 2

b)

B) 3

c)

C) 4

d)

D) Error

27.

FUNCTION fun(n)

IF n == 0

RETURN 1

ELSE

RETURN n * fun(n-1)

END FUNCTION

PRINT fun(4)

a)

A) 10

b)

B) 16

c)

C) 24

d)

D) 120

28.

FOR i = 1 TO n

FOR j = 1 TO n

PRINT i, j

END FOR

END FOR

Time Complexity?

a)

A) O(n)

b)

B) O(n log n)

c)

C) O(n²)

d)

D) O(2n)