Font size
Worksheets202508500002
Total questions: 40
Worksheet time: 40mins
What is a Schema in a Relational Database?
A graphical representation of data relationships
A collection of related tables
A blueprint that defines the structure of the database
A database query language
A type of database key
Which of the following statements about indexing is/are true?
Indexes speed up data retrieval operations
Indexes increase the size of the database
Indexes are automatically created on all columns
Indexes can be created only on primary key columns
Indexes can replace the need for primary keys
Which SQL query returns employees who earn more than the average salary?
SELECT * FROM employees WHERE salary > AVG(salary);
SELECT * FROM employees WHERE salary > (SELECT AVG(salary) FROM employees);
SELECT * FROM employees HAVING salary > AVG(salary);
SELECT * FROM employees GROUP BY salary > AVG(salary);
SELECT * FROM employees WHERE salary = MAX(salary);
Which SQL statement(s) can be used to rename a column?
ALTER TABLE table_name RENAME COLUMN old_name TO new_name;
MODIFY TABLE table_name CHANGE old_name new_name datatype;
UPDATE COLUMN table_name SET new_name;
ALTER COLUMN table_name RENAME old_name new_name;
ALTER TABLE table_name ALTER COLUMN old_name RENAME TO new_name;
Which statements about the IN and EXISTS operators are true?
IN is generally faster than EXISTS
EXISTS returns TRUE if the subquery returns at least one row
IN cannot be used with subqueries
EXISTS is more efficient in correlated subqueries
Both IN and EXISTS can return NULL
Which query returns the count of employees per job title sorted in descending order of count?
SELECT job_title, COUNT(*) FROM employees GROUP BY job_title ORDER BY job_title DESC;
SELECT job_title, COUNT(*) FROM employees GROUP BY job_title ORDER BY COUNT(*) DESC;
SELECT COUNT(job_title) FROM employees ORDER BY COUNT(*) DESC;
SELECT job_title, COUNT(*) FROM employees ORDER BY job_title;
SELECT COUNT(*) FROM employees GROUP BY job_title DESC;
Which query finds the total salary per department for departments with more than 2 employees?
SELECT department_id, SUM(salary) FROM employees GROUP BY department_id HAVING COUNT(*) > 2;
SELECT department_id, salary FROM employees HAVING COUNT(*) > 2;
SELECT department_id, SUM(salary) FROM employees WHERE COUNT(*) > 2;
SELECT SUM(salary) FROM employees GROUP BY salary;
SELECT department_id, salary FROM employees WHERE salary > 50000;
What is the purpose of the CASE statement in SQL?
Perform conditional logic in queries
Check table constraints
Create temporary tables
Define views
Execute subqueries
You're using 3NF, but find that data anomalies still occur due to transitive dependencies. What should you normalize to?
2NF
BCNF
4NF
3NF
A transaction must ensure other transactions cannot view its intermediate states. Which ACID property is this?
Atomicity
Consistency
Isolation
Durability
Idempotency
Which concept allows an object to behave differently in different contexts?
Encapsulation
Inheritance
Polymorphism
Composition
Static binding
What is the outcome of calling a method that’s been overloaded, not overridden?
Runtime resolution
Static (compile-time) resolution
Causes ambiguity
Calls base method
Depends on inheritance
Which relationship is shown by ‘has-a’?
Inheritance
Composition
Abstraction
Polymorphism
Overloading
Which scenario would best use method overloading?
Multiple classes with same method
One class needing same method with different params
Runtime polymorphism
Changing behavior at runtime
Inheriting class functionality
A class User has fields name, email, password that should not be accessible from outside. You use private access modifier. This is:
Polymorphism
Abstraction
Inheritance
Encapsulation
Delegation
A subclass redefines a method from its superclass. What is this called?
Overloading
Overriding
Overruling
None of the mentioned
Masking
Given an array of n integers, how many distinct pairs (i, j) exist such that arr[i] + arr[j] = target in O(n) time?
Use two loops
Use a hash set
Use sorting
Use sliding window
Use merge sort
What is the best time complexity to search for an element in a sorted and rotated array?
O(n)
O(log n)
O(1)
O(n log n)
O(n²)
What is the minimum number of swaps required to sort an array of size n using cycle detection?
O(n²)
O(log n)
O(n log n)
O(n)
O(1)
Which of the following is used to implement two stacks in an array without wastage of space?
Push one after another
Use two arrays
Divide array equally
One from start and one from end
Use doubly linked list
Which data structure is most efficient for implementing an LRU Cache?
Queue only
Stack and array
Hash Map + Doubly Linked List
BST
Graph
Which problem can be optimally solved using a monotonic stack?
Binary Tree traversal
Longest Common Subsequence
Next Greater Element
Kruskal’s algorithm
Sliding window maximum
What’s the maximum number of edges in a directed graph with n nodes and no self-loops?
n(n+1)
n²
n(n–1)
2n
n(n–1)/2
Which sorting algorithm is stable and not in-place?
Heap Sort
Quick Sort
Merge Sort
Selection Sort
Shell Sort
Which of these sorting algorithms has O(n²) time in both best and worst case?
Bubble Sort
Merge Sort
Insertion Sort
Quick Sort
Counting Sort
Which sorting algorithm is not comparison-based?
Merge Sort
Counting Sort
Quick Sort
Bubble Sort
Heap Sort
Which sorting algorithm is least efficient on large data?
Quick Sort
Merge Sort
Bubble Sort
Heap Sort
Counting Sort
Which of the following problems is best solved using Dynamic Programming?
Binary Search
Tower of Hanoi
Longest Increasing Subsequence
Tree Traversal
Depth First Search
Which technique helps to reduce space complexity in bottom-up DP?
Tree traversal
Memoization
Tabulation
State compression
Randomization
Which of the following problems is not typically solved using dynamic programming?
Longest Common Subsequence
Matrix Chain Multiplication
Dijkstra's Algorithm
Longest Increasing Subsequence
Coin Change
What is the main idea of overlapping subproblems in DP?
Problems depend on previous state
Same subproblems solved multiple times
Problems cannot be divided
Problems are unrelated
Subproblems do not require storage
Which method is used in solving Longest Palindromic Subsequence using DP?
Sliding window
Hashing
Two-pointer
Reverse string and find LCS
Stack-based
Round Robin scheduling is most suitable for:
Long batch jobs
Real-time systems
Interactive systems
High throughput
Low latency tasks
The working set model is used for:
Deadlock prevention
Cache replacement
Memory management
Disk scheduling
Multithreading
Which statement about threads is false?
Threads share memory
Threads are faster to create
Threads can’t run on separate cores
Threads have their own stack
Threads allow better parallelism
A system with 4 resources and processes with maximum need vectors: P1: (3), P2: (2), P3: (2) If all request 1 instance, will it be in a safe state?
Yes
No
Depends on order
Unsafe
Can’t determine
The Banker's Algorithm is used for:
CPU scheduling
Deadlock detection
Memory allocation
Deadlock avoidance
File system protection
What is the purpose of subnet mask?
Encrypt traffic
Find default gateway
Determine network and host portion
Assign DNS
Set TTL
What’s the advantage of IPv6 over IPv4?
Less bandwidth
Shorter addresses
More address space
Easier subnetting
Lower latency
Which protocol supports connectionless communication?
TCP
FTP
UDP
SSH
Telnet
