OS, DBMS & Networks Aptitude Questions with Solutions
40 OS, DBMS & Networks questions with hints, worked solutions and time targets — 12 easy · 21 medium · 7 hard.
- Section: Programming MCQs
- Questions: 40
- By difficulty: 12 easy · 21 medium · 7 hard
- Cost: Free, unlimited on every plan
Core computer science: processes, scheduling, SQL, normalisation and the OSI layers.
OS, DBMS & Networks: the essentials
Three subjects, each asked as short facts and small calculations.
Operating systems
- Turnaround = completion − arrival; waiting = turnaround − burst.
- Scheduling: FCFS suffers the convoy effect; non-preemptive SJF gives the least average waiting time and SRTF is its preemptive form; round robin with a huge quantum becomes FCFS.
- Deadlock needs mutual exclusion, hold and wait, no preemption and circular wait at once. P processes needing at most N units each cannot deadlock with P(N − 1) + 1 units.
- Paging: 32-bit addresses with 4 KB pages give 2³² ÷ 2¹² = 2²⁰ page-table entries. With a TLB, EMAT = h(t + m) + (1 − h)(t + 2m). FIFO can show Belady's anomaly; LRU cannot.
- Threads share code, data and files but keep their own stack and registers.
DBMS and networks
- Normal forms: 2NF removes partial dependencies, 3NF transitive ones; BCNF needs every determinant to be a superkey.
- SQL runs FROM, WHERE, GROUP BY, HAVING, SELECT, ORDER BY: WHERE filters rows, HAVING filters groups.
COUNT(*)counts rows; other aggregates skip NULLs. - TRUNCATE is DDL, DELETE is DML.
- OSI: switches work at layer 2 (MAC), routers at 3 (IP), ports at 4.
- TCP is reliable and opened by SYN, SYN-ACK, ACK; UDP gives no guarantees. Ports: 22 SSH, 25 SMTP, 53 DNS, 80 HTTP, 443 HTTPS.
- Usable hosts in a subnet = 2^(32 − prefix) − 2, so a /26 has 62.
Questions
- Average waiting time under FCFS Medium
Three processes arrive together at time 0, in the order P1, P2, P3: Under first-come first-served scheduling, what is the average waiting time? - Average waiting time under SJF Medium
Four processes are all present at time 0: Under non-preemptive shortest-job-first scheduling, what is the average waiting time? - Round robin with a quantum of 4 Medium
Three processes arrive together at time 0, in the order P1, P2, P3: Under round-robin scheduling with a time quantum of 4, what is the average waiting time? - Preemptive shortest remaining time first Hard
Four processes arrive at different times: Under shortest-remaining-time-first (preemptive SJF) scheduling, what is the average waiting time? - The four deadlock conditions Easy
Which of these is not one of the four necessary conditions for deadlock? - Numbering the resources Medium
An operating system numbers every resource and insists that a process request resources only in increasing order of number. - Units needed to rule out deadlock Hard
Four processes share identical units of a single resource, and each process may need up to 3 units to finish. - Counting FIFO page faults Medium
A process references the pages 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5. With three frames and FIFO replacement, how many page faults occur? - Counting LRU page faults Medium
A process references the pages 7, 0, 1, 2, 0, 3, 0, 4. With three frames and LRU replacement, how many page faults occur? - Belady's anomaly Easy
Belady's anomaly — adding a frame producing more page faults — can occur with which page-replacement algorithm? - Size of a page table Medium
A system uses 32-bit logical addresses with a page size of 4 KB. How many entries does a single-level page table contain? - Effective memory access time Hard
A paged system has a TLB hit ratio of 80%. A TLB lookup takes 20 ns and a memory access takes 100 ns. - Internal fragmentation Easy
Which memory-management scheme suffers from internal fragmentation? - What threads do not share Easy
Two threads belong to the same process. Which of these does each thread keep private? - Value of a counting semaphore Medium
A counting semaphore is initialised to 10. Six wait (P) operations and four signal (V) operations are then completed on it. What is its value? - Which normal form is it in? Medium
A relation R(A, B, C, D) has A as its only candidate key, with the functional dependencies A → B, B → C and A → D. What is the highest normal form R satisfies? - The gap between 3NF and BCNF Hard
A relation R(A, B, C) has the functional dependencies AB → C and C → B. What is the highest normal form R satisfies? - Counting candidate keys Hard
For R(A, B, C, D) with the functional dependencies AB → C, C → D and D → A, how many candidate keys does R have? - GROUP BY with HAVING Medium
Table employee: What does this query return? - COUNT and NULL Medium
Table employee: What does this query return? - Rows from a left outer join Medium
Two tables: students marks How many rows does this query return? - Largest possible natural join Medium
R(A, B) holds 200 tuples and S(B, C) holds 100 tuples. What is the maximum possible number of tuples in the natural join of R and S? - Where an alias may be used Medium
Why can a column alias defined in the SELECT list be referenced in ORDER BY but not in WHERE? - TRUNCATE against DELETE Easy
Which command removes every row of a table while keeping the table itself, and is classed as DDL rather than DML? - Surviving a crash Easy
A transaction commits and the server loses power a second later. - Choosing an isolation level Medium
Which isolation level prevents dirty reads but still permits non-repeatable reads? - Clustered indexes Medium
Which statement about a clustered index is correct? - PRIMARY KEY against UNIQUE Easy
What distinguishes a PRIMARY KEY constraint from a UNIQUE constraint? - Where a router works Easy
A router forwards packets by examining destination IP addresses. At which OSI layer does it operate? - The translation layer Easy
Which OSI layer handles encryption, compression and the translation of data between different character representations? - TCP against UDP Medium
Which of these statements about TCP is false? - The three-way handshake Easy
What is the correct order of segments in the TCP three-way handshake? - The port DNS uses Easy
Which well-known port does DNS use by default? - Which DNS record Easy
Which DNS record type maps a host name to an IPv4 address? - Hosts in a /26 Medium
How many usable host addresses does an IPv4 subnet with a /26 prefix provide? - Finding the broadcast address Hard
A host is configured with the address 192.168.10.75 and the subnet mask 255.255.255.192. What is the broadcast address of its subnet? - Reading an HTTP status code Medium
A server fully understands a request but refuses to authorise it, and repeating the request with the same credentials will not help. - Collision and broadcast domains Medium
A single 24-port Ethernet switch has one host on each port and no VLANs configured. How many collision domains and broadcast domains exist? - Flow control in TCP Medium
Which mechanism does TCP use for flow control — that is, to stop a fast sender from overwhelming a slow receiver? - Window size in Go-Back-N Hard
A Go-Back-N protocol numbers its frames with a 4-bit sequence number. What is the largest sender window it may use?
Placement tests that ask os, dbms & networks
- Full-Length Aptitude Paper CodeKairo
- Big Tech Screen — Theory Drill CodeKairo
- Accenture — Cognitive & Technical Accenture
- Capgemini — Technical & English Capgemini
- HCLTech — Written Test HCLTech
- Tech Mahindra — Aptitude & Technical Tech Mahindra
- LTIMindtree — Online Assessment LTIMindtree
- Virtusa — Online Test & Coder Challenge Virtusa
- Deloitte — Online Assessment Deloitte
- Morgan Stanley — Aptitude & Technical Morgan Stanley