wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

202508500001

Total questions: 40

Worksheet time: 21mins

Name
Class
Date
1.

In OOP, what is delegation?

a)

Overriding base method

b)

Passing responsibility to another object

c)

Inheriting from multiple classes

d)

Creating private methods

e)

Applying a constructor

2.

What is the outcome of calling a method that’s been overloaded, not overridden?

a)

Runtime resolution

b)

Static (compile-time) resolution

c)

Causes ambiguity

d)

Calls base method

e)

Depends on inheritance

3.

Which of the following is a violation of encapsulation?

a)

Using getter methods

b)

Making all variables public

c)

Making methods private

d)

Declaring variables protected

e)

Defining constructors

4.

In which situation would you prefer an interface over an abstract class?

a)

You want to reuse code

b)

You want multiple inheritance

c)

You have default implementation

d)

You need private constructors

e)

You want final methods

5.

Which concept allows an object to behave differently in different contexts?

a)

Encapsulation

b)

Inheritance

c)

Polymorphism

d)

Composition

e)

Static binding

6.

The Decorator pattern is used to:

a)

Allow dynamic behavior extension

b)

Compress data

c)

Authenticate users

d)

Avoid subclassing

e)

Enforce abstraction

7.

You are given an array of integers. Which algorithm efficiently finds the majority element (occurs more than n/2 times)?

a)

Merge Sort

b)

Binary Search

c)

Kadane’s

d)

Boyer-Moore Voting Algorithm

e)

Floyd-Warshall

8.

What is the best time complexity to search for an element in a sorted and rotated array?

a)

O(n)

b)

O(log n)

c)

O(1)

d)

O(n log n)

e)

O(n²)

9.

Which approach is optimal to find the smallest missing positive number in an unsorted array?

a)

Sorting

b)

HashMap

c)

In-place Indexing

d)

Binary Search

e)

Greedy

10.

Which of the following is used to implement two stacks in an array without wastage of space?

a)

Push one after another

b)

Use two arrays

c)

Divide array equally

d)

One from start and one from end

e)

Use doubly linked list

11.

What’s the optimal way to design a circular queue using array?

a)

Push from front

b)

Push using two arrays

c)

Use front and rear pointers with modulo

d)

Doubly Linked List

e)

Prefix tree

12.

In a queue implemented using two stacks, what ensures amortized O(1) dequeue?

a)

Transfer on every operation

b)

Use priority queue

c)

Transfer only when needed

d)

Use three stacks

e)

FIFO list

13.

Which traversal is used to serialize/deserialize a binary tree without ambiguity?

a)

In-order

b)

Post-order

c)

Level-order

d)

Pre-order

e)

Any traversal

14.

In a Binary Tree, the diameter is the:

a)

Max number of leaves

b)

Depth of root

c)

Longest path between any two nodes

d)

Height + width

e)

Sum of left subtree

15.

What is the maximum number of nodes in a binary tree of height h?

a)

2^h

b)

2^h – 1

c)

2^(h+1) – 1

d)

e)

log h

16.

Which condition must be satisfied for a binary tree to be complete?

a)

Every node has 2 children

b)

All leaves are at same depth

c)

All levels are filled except possibly last

d)

Only root has two children

e)

Balanced height difference < 1

17.

Which algorithm finds all pairs shortest paths in a graph?

a)

Dijkstra

b)

Prim

c)

Floyd-Warshall

d)

DFS

e)

Kruskal

18.

Which traversal ensures the shortest path in unweighted graphs?

a)

DFS

b)

BFS

c)

Dijkstra

d)

Topological

e)

Kruskal

19.

Which sorting is NOT stable?

a)

Merge Sort

b)

Insertion Sort

c)

Bubble Sort

d)

Heap Sort

e)

Tim Sort

20.

What is strongly connected component (SCC) in a directed graph?

a)

A cycle

b)

Nodes connected to a root

c)

Every node is reachable from every other node

d)

Graph with in-degree = out-degree

e)

MST root node

21.

Which graph representation is more efficient for sparse graphs?

a)

Adjacency Matrix

b)

Incidence Matrix

c)

Adjacency List

d)

Edge List

e)

Cartesian Matrix

22.

Which algorithm performs better for nearly sorted arrays?

a)

Bubble Sort

b)

Merge Sort

c)

Insertion Sort

d)

Quick Sort

e)

Selection Sort

23.

Which technique helps to reduce space complexity in bottom-up DP?

a)

Tree traversal

b)

Memoization

c)

Tabulation

d)

State compression

e)

Randomization

24.

Which technique converts a recursive algorithm into a bottom-up form?

a)

Top-down DP

b)

Memoization

c)

Tabulation

d)

Divide and Conquer

e)

Greedy method

25.

In the Longest Common Subsequence (LCS) problem, what does dp[i][j] represent?

a)

The length of the input strings

b)

Whether substrings match

c)

The LCS of first i characters of string A and first j of B

d)

Number of matches found so far

e)

None of the above

26.

What’s the optimal substructure property in DP?

a)

Solutions are always unique

b)

Bigger problems depend on smaller ones

c)

All solutions are exponential

d)

Subproblems are disjoint

e)

Uses greedy decisions

27.

The Banker's Algorithm is used for:

a)

CPU scheduling

b)

Deadlock detection

c)

Memory allocation

d)

Deadlock avoidance

e)

File system protection

28.

What is thrashing in OS?

a)

Frequent page faults

b)

Buffer overflow

c)

Deadlock

d)

File fragmentation

e)

Process starvation

29.

Which condition is necessary for a deadlock to occur?

a)

Starvation

b)

Cyclic wait

c)

CPU-bound processes

d)

Spooling

e)

Preemption

30.

Which one is used in LRU page replacement?

a)

FIFO queue

b)

Priority queue

c)

Stack

d)

Circular queue

e)

Random selection

31.

Which one is a Class C IPv4 address?

a)

126.22.33.4

b)

191.255.255.255

c)

200.1.1.1

d)

10.0.0.1

e)

224.1.1.1

32.

Which of the following is not connection-oriented?

a)

TCP

b)

SCTP

c)

FTP

d)

UDP

e)

Telnet

33.

Which function is used to assign a unique sequential integer to rows within a result set partition?

a)

DENSE_RANK()

b)

RANK()

c)

ROW_NUMBER()

d)

PARTITION()

e)

NTILE()

34.

Which query finds employees who earn the same as someone in department 10?

a)

SELECT *

FROM employees

WHERE salary IN (SELECT salary FROM employees WHERE department_id = 10);

b)

SELECT *

FROM employees

WHERE salary = salary IN department 10; 

c)

SELECT *

FROM employees

WHERE salary BETWEEN (SELECT MIN(salary) FROM employees WHERE department_id = 10)

AND (SELECT MAX(salary) FROM employees WHERE department_id = 10); 

d)

SELECT *

FROM employees

GROUP BY salary = department_id; 

e)

SELECT salary

FROM employees

HAVING department_id = 10;

35.

What is true about the following query?

SELECT * FROM employees e1

WHERE EXISTS (

  SELECT 1 FROM employees e2

  WHERE e1.salary = e2.salary AND e1.employee_id <> e2.employee_id

);

a)

Returns all employees with unique salaries

b)

Returns employees who share the same salary with others

c)


Returns NULL

d)

Returns top-paid employees

e)


Returns department heads

36.

The __________ clause is used in a SELECT query to group rows sharing a common field.

a)

HAVING

b)


PARTITION

c)


GROUP BY

d)


AGGREGATE

e)


UNION

37.

The __________ operator is used to combine the results of two SELECT statements and include all rows.

a)

JOIN

b)


UNION

c)


UNION ALL

d)


INTERSECT

e)


COMBINE

38.

Which statements are correct regarding foreign keys?

a)

A table can have only one foreign key

b)


A foreign key must reference a primary or unique key

c)


Foreign key values must always be unique

d)


Foreign key enforces referential integrity

e)


Foreign keys are always nullable

39.

Which statements about 3NF (Third Normal Form) are true?

a)

It removes transitive dependencies

b)

Every non-prime attribute is fully functionally dependent on the candidate key

c)

It allows partial dependencies

d)

It eliminates foreign keys

e)

It denormalizes data

40.

What does the UNION operator do?

a)

Combines rows and removes duplicates

b)


Joins two tables

c)


Combines rows with duplicates

d)


Merges databases

e)


Overwrites rows with common data