Skip to content

CS Fundamentals Quick Sheet โ€” OOPS, OS, DBMS

One-pager style. Read in 60 minutes. Revise the day before interview.


PART 1: OOPS (Object-Oriented Programming)

The 4 Pillars โ€” "A PIE"

Letter Pillar One-liner
A Abstraction Hide complexity, show only needed parts
P Polymorphism One name, many forms
I Inheritance Child reuses parent's properties
E Encapsulation Bundle data + methods, protect using access modifiers

1. Abstraction

  • What: Show what an object does, hide how.
  • Example: When you drive a car, you press the accelerator โ€” you don't think about fuel injection.
  • Java: abstract class, interface.

2. Encapsulation

  • What: Wrap data and code into a single unit; restrict access via private + getters/setters.
  • Example: Bank account โ€” balance is private; only deposit() and withdraw() can change it.

3. Inheritance

  • What: Child class inherits parent's properties.
  • Types: Single, Multilevel, Hierarchical, Multiple (via interfaces in Java).
  • Example: Car extends Vehicle.

4. Polymorphism

  • Compile-time (Method Overloading): Same name, different parameters.
  • Run-time (Method Overriding): Child redefines parent's method.

Overloading vs Overriding (Common Q)

Overloading Overriding
When Compile time Run time
Class Same class Parent-Child
Signature Different Same

SOLID Principles (Bonus)

  • S โ€” Single Responsibility (one class = one job)
  • O โ€” Open/Closed (open for extension, closed for modification)
  • L โ€” Liskov Substitution (child can replace parent)
  • I โ€” Interface Segregation (small, specific interfaces)
  • D โ€” Dependency Inversion (depend on abstractions, not concretions)

Class vs Object

  • Class = blueprint. Object = real-world instance.
  • Example: Class = Recipe, Object = Actual cake baked.

Constructor vs Method

  • Constructor: Same name as class, no return type, called once when object is created.
  • Method: Has return type, called whenever invoked.

this vs super

  • this โ†’ current object. super โ†’ parent class.

Interface vs Abstract Class

Interface Abstract Class
Methods All abstract (Java 7); default+static (Java 8+) Both abstract + concrete
Variables public static final Any
Multiple inheritance Yes No
Use when Pure contract Shared base behavior

PART 2: OPERATING SYSTEM

Core Topics โ€” "PMFDS"

P=Process, M=Memory, F=File, D=Deadlock, S=Scheduling.

1. Process vs Thread

  • Process: Independent program in execution; has own memory.
  • Thread: Lightweight process; shares memory with parent.
  • Example: Chrome = process; each tab loading = thread.

2. Process States

New โ†’ Ready โ†’ Running โ†’ Waiting โ†’ Terminated

3. CPU Scheduling Algorithms

Algo Meaning Memory trick
FCFS First Come First Serve Like a queue at billing
SJF Shortest Job First Fast tasks first
Round Robin Time slices Fair turn-by-turn
Priority Higher priority first VIP gets served

4. Deadlock โ€” 4 Conditions ("MHNC")

  • Mutual Exclusion
  • Hold and Wait
  • No Preemption
  • Circular Wait

Example: Two cars in a narrow lane, both refuse to reverse โ†’ deadlock.

Prevention: Break any one of the 4 conditions. Avoidance: Banker's algorithm.

5. Memory Management

  • Paging: Fixed-size blocks (pages).
  • Segmentation: Variable-size blocks based on logical division.
  • Virtual Memory: Uses disk as extended RAM (swap space).

6. Thrashing

When OS spends more time swapping pages than executing โ†’ performance crashes.

7. Semaphore vs Mutex

  • Mutex: Lock (only one holder at a time).
  • Semaphore: Counter (allows N holders).

8. IPC (Inter-Process Communication)

Pipes, Message Queues, Shared Memory, Sockets.

9. Kernel

Core of OS โ€” manages CPU, memory, I/O.

10. System Call

Programs request services from OS (e.g., read(), write()).


PART 3: DBMS

Memory Hook โ€” "NACID-JINK"

N=Normalization, A=ACID, C=Cardinality, I=Indexing, D=Denormalize, J=Joins, I=Isolation, N=Null, K=Keys.

1. DBMS vs RDBMS

  • DBMS: Stores data as files (no relations).
  • RDBMS: Data stored in tables, supports relations (MySQL, Postgres).

2. Keys

Key Meaning
Primary Key Unique + Not Null โ€” identifies a row
Foreign Key Refers to PK of another table
Candidate Key Could be primary key
Composite Key PK made of 2+ columns
Unique Key Unique but can have one NULL

3. Normalization

Form Rule
1NF Atomic values, no repeating groups
2NF 1NF + no partial dependency
3NF 2NF + no transitive dependency
BCNF Stricter version of 3NF

Why? Reduce redundancy, prevent anomalies.

4. Denormalization

Add redundancy back for faster reads (analytics dashboards, reporting).

5. ACID Properties

Meaning
Atomicity All or nothing
Consistency DB moves from one valid state to another
Isolation Concurrent txns don't interfere
Durability Once committed, always saved (even on crash)

Example: Bank transfer โ€” debit + credit either both succeed or both fail (Atomicity).

6. Transaction Isolation Levels (Low โ†’ High)

  1. Read Uncommitted โ€” dirty reads possible
  2. Read Committed โ€” no dirty reads
  3. Repeatable Read โ€” no dirty + non-repeatable reads
  4. Serializable โ€” full isolation (slowest)

7. Joins (Critical for SDETs!)

Join Meaning
INNER JOIN Only matching rows
LEFT JOIN All left + matching right
RIGHT JOIN All right + matching left
FULL OUTER All rows from both
CROSS JOIN Cartesian product
SELF JOIN Table joined with itself
SELECT u.name, o.amount
FROM users u
LEFT JOIN orders o ON u.id = o.user_id;

8. Indexing

  • Like a book index โ€” speeds up lookups.
  • Types: Clustered (data sorted by index), Non-clustered (separate structure).
  • Cost: Slows down INSERT/UPDATE.

9. SQL vs NoSQL

SQL NoSQL
Schema Fixed Flexible
Scale Vertical Horizontal
Example MySQL, Postgres MongoDB, Cassandra
Best for Structured data, ACID Big data, fast iteration

10. Common SQL Queries (SDET must know)

-- 2nd highest salary
SELECT MAX(salary) FROM employees
WHERE salary < (SELECT MAX(salary) FROM employees);

-- Nth highest (using DENSE_RANK)
SELECT salary FROM (
  SELECT salary, DENSE_RANK() OVER (ORDER BY salary DESC) AS rnk
  FROM employees
) t WHERE rnk = N;

-- Duplicate rows
SELECT name, COUNT(*) FROM users
GROUP BY name HAVING COUNT(*) > 1;

-- Delete duplicates keep one
DELETE FROM users
WHERE id NOT IN (SELECT MIN(id) FROM users GROUP BY email);

-- Join example (orders per user)
SELECT u.name, COUNT(o.id) AS order_count
FROM users u LEFT JOIN orders o ON u.id = o.user_id
GROUP BY u.name;

11. WHERE vs HAVING

  • WHERE: filters rows before grouping.
  • HAVING: filters groups after GROUP BY.

12. UNION vs UNION ALL

  • UNION: removes duplicates.
  • UNION ALL: keeps duplicates (faster).

13. Stored Procedure vs Function

  • Procedure: Can do DML, no return required.
  • Function: Must return a value, used in SELECT.

14. View

Virtual table from a query. Used to simplify or restrict data access.

15. Trigger

Auto-runs on INSERT/UPDATE/DELETE.


Final Tip for SDET

Interviewers love testing SQL + Joins for QA roles because backend data validation is part of your job. Be very confident with: - JOINs - GROUP BY + HAVING - Window functions (RANK, ROW_NUMBER) - Subqueries