TechHire NepalConnecting Talent, Building Careers
Find JobsCompaniesCourses
Find Talents
Sign inGet Started →
Find JobsCompaniesCourses
Find Talents
Sign inGet StartedHire Talent
TechHire Nepal

Nepal's #1 tech job platform. Connecting top talent with the best companies.

For Job Seekers

  • Browse Jobs
  • Companies
  • Tech Salaries
  • Interview Prep
  • Courses
  • Career Advice

For Employers

  • Post a Job
  • Talent Search
  • Pricing
  • Employer Dashboard

Company

  • About
  • Blog
  • Careers
  • Contact

Resources

  • Training Institutes
  • Projects
  • Tutorials
  • Roadmaps
  • Notes
  • Open Sources

Community

  • Discussions
  • Tech Events
  • Hackathons
  • Developer Meetups
  • Tech News

More

  • Help & Support
  • Salary Tax Calculator
  • Company Registration Guide
  • Labour Act

Stay in the loop

A weekly digest of the best tech articles and jobs in Nepal.

© 2026 TechHire Nepal. All rights reserved.

Privacy PolicyTerms of ServiceCookie Policy
HomeInterview PrepQuestion bank
Question bank

Interview Questions, Answered Clearly

Filter by the role you are applying for, open a question, and practise explaining the answer out loud. Mark it practised when you can.

Type
TechnicalCodingHR / BehaviouralAll types
Role
All rolesFrontend DeveloperBackend DeveloperFull-Stack DeveloperMobile Developer
Topic
All topicsJavaScript10React7HTML & CSS7PHP & Laravel9SQL & Databases6HTTP & REST APIs6Git4OOP & Design4Flutter5React Native5
Level
AnyEasyMediumHard

63 questions

  • Why they ask this: Core relational design knowledge for any backend role.

    Answer

    • Primary key: uniquely identifies each row. It cannot be NULL, and a table has only one (it can span several columns, a composite key).
    • Foreign key: a column that references the primary key of another table. It enforces referential integrity, so you cannot add a job for a company that does not exist. Use ON DELETE CASCADE or SET NULL to decide what happens when the parent row is deleted.
    • Unique key: guarantees no duplicate values in a column, such as email. A table can have many. In MySQL and PostgreSQL a unique column can hold several NULLs.
    sql
    CREATE TABLE jobs (
      id BIGINT PRIMARY KEY AUTO_INCREMENT,
      company_id BIGINT NOT NULL,
      slug VARCHAR(255) NOT NULL UNIQUE,
      FOREIGN KEY (company_id) REFERENCES companies(id) ON DELETE CASCADE
    );
    Open full page
  • Why they ask this: Indexes are the first tool for slow queries; this checks real-world database thinking.

    Answer

    An index is a separate data structure (usually a B-tree) that lets the database find rows without scanning the whole table, much like the index at the back of a book.

    Benefits: much faster WHERE, JOIN, ORDER BY and lookups on the indexed columns.

    Trade-offs:

    • Writes (INSERT, UPDATE, DELETE) get slower because every index must be updated too.
    • Indexes use extra disk space and memory.
    • Indexes on columns with few distinct values (such as a boolean) rarely help on their own.

    Composite indexes follow the leftmost-prefix rule: an index on (status, created_at) helps WHERE status = ? and WHERE status = ? ORDER BY created_at, but not WHERE created_at > ? alone.

    sql
    CREATE INDEX jobs_status_created_at_index ON jobs (status, created_at);
    EXPLAIN SELECT * FROM jobs WHERE status = 'open' ORDER BY created_at DESC;

    Use EXPLAIN to check whether a query actually uses an index.

    Open full page
  • Why they ask this: A favourite academic and interview topic in Nepal; it also shows you can design clean schemas.

    Answer

    Normalisation organises tables to remove duplicate data and the update problems it causes.

    • 1NF: every column holds a single (atomic) value and there are no repeating groups. Not skills = "PHP, SQL"; use a separate row per skill.
    • 2NF: 1NF, and every non-key column depends on the whole primary key. This matters for composite keys: in (student_id, course_id) → student_name, the name depends only on student_id, so move it to a students table.
    • 3NF: 2NF, and non-key columns depend only on the key, not on other non-key columns (no transitive dependency). If employees stores department_id and department_name, move the name to a departments table.

    Sometimes you denormalise on purpose for read performance, for example by storing a jobs_count on companies. Do it knowingly and keep the copy in sync.

    Open full page
  • Why they ask this: A common online-test question that checks you understand how GROUP BY queries run.

    Answer

    • WHERE filters rows before grouping. It cannot use aggregate functions.
    • HAVING filters groups after GROUP BY. It can use aggregates such as COUNT and AVG.
    sql
    -- Companies in Kathmandu with more than 5 open jobs
    SELECT company_id, COUNT(*) AS open_jobs
    FROM jobs
    WHERE status = 'open' AND city = 'Kathmandu'   -- row filter
    GROUP BY company_id
    HAVING COUNT(*) > 5;                            -- group filter

    The logical order is FROM → WHERE → GROUP BY → HAVING → SELECT → ORDER BY → LIMIT. Filter in WHERE whenever you can, because it reduces the rows that need grouping.

    Open full page
  • Why they ask this: Payments and orders must never be half-saved; this checks you can protect data consistency.

    Answer

    A transaction groups several statements so that they all succeed or all fail together.

    ACID:

    • Atomicity: all or nothing. On error, everything is rolled back.
    • Consistency: the data moves from one valid state to another and constraints still hold.
    • Isolation: concurrent transactions do not see each other's half-finished work (the exact level depends on the isolation level).
    • Durability: once committed, the data survives a crash.
    php
    DB::transaction(function () use ($order, $payment) {
        $payment->update(['status' => 'paid']);
        $order->update(['status' => 'confirmed']);
        $order->product->decrement('stock', $order->quantity);
    }); // any exception rolls back all three

    Classic example: a bank transfer debits one account and credits another. Both must happen, or neither.

    Open full page
  • Why they ask this: Every developer calls or builds APIs; correct method use is a basic expectation.

    Answer

    MethodUseSafeIdempotent
    GETread a resourceyesyes
    POSTcreate a resource or trigger an actionnono
    PUTreplace a resource completelynoyes
    PATCHupdate part of a resourcenonot guaranteed
    DELETEremove a resourcenoyes
    • Safe means the request does not change server data.
    • Idempotent means sending the same request several times leaves the server in the same state as sending it once. Two identical POST /orders calls can create two orders, while PUT /users/5 with the same body twice gives the same result.

    This matters for retries: clients and proxies can safely retry idempotent requests after a network error. For payments, use an idempotency key to make POST safe to retry.

    Open full page
  • Why they ask this: Correct status codes make APIs predictable for frontend and mobile developers.

    Answer

    • 2xx success: 200 OK, 201 Created (after a POST that creates something), 204 No Content (success with no body).
    • 3xx redirect: 301 Moved Permanently, 302 Found, 304 Not Modified (use the cached copy).
    • 4xx client error:
      • 400 Bad Request: malformed request.
      • 401 Unauthorized: not authenticated (no token or a bad token).
      • 403 Forbidden: authenticated but not allowed.
      • 404 Not Found.
      • 409 Conflict: for example a duplicate email.
      • 422 Unprocessable Content: validation errors (Laravel's default).
      • 429 Too Many Requests: rate limited.
    • 5xx server error: 500 Internal Server Error, 502 Bad Gateway, 503 Service Unavailable.

    A frequent interview trap is the difference between 401 and 403.

    Open full page
  • Why they ask this: Most backend roles in Nepal build JSON APIs for web and mobile clients.

    Answer

    REST (Representational State Transfer) is an architectural style for APIs built on HTTP. Key ideas:

    • Resources are identified by URLs using nouns: /jobs, /jobs/42, /companies/7/jobs.
    • HTTP methods express the action: GET /jobs lists, POST /jobs creates, PATCH /jobs/42 updates, DELETE /jobs/42 deletes.
    • Stateless: each request carries everything needed (such as the auth token). The server keeps no client session between requests.
    • Representations: usually JSON, with the right Content-Type.
    • Correct status codes and a consistent error format.
    • Cacheable responses where appropriate.

    Good practice: version the API (/api/v1), paginate lists, use plural nouns and avoid verbs in URLs (POST /jobs/42/applications, not /applyJob).

    Open full page
  • Why they ask this: Every frontend developer meets CORS errors when calling an API on another domain.

    Answer

    Browsers enforce the same-origin policy: JavaScript on https://app.example.com cannot read responses from a different origin (scheme + host + port), such as https://api.example.com, unless that server allows it.

    CORS (Cross-Origin Resource Sharing) is how the server grants permission, using response headers such as:

    text
    Access-Control-Allow-Origin: https://app.example.com
    Access-Control-Allow-Methods: GET, POST, PATCH, DELETE
    Access-Control-Allow-Headers: Content-Type, Authorization
    Access-Control-Allow-Credentials: true

    For non-simple requests (for example JSON bodies or an Authorization header) the browser first sends a preflight OPTIONS request.

    Fix it on the server, not in the frontend: in Laravel, set allowed_origins in config/cors.php. Avoid * when cookies or credentials are involved; browsers reject that combination anyway. CORS is enforced by browsers only; Postman and server-to-server calls ignore it.

    Open full page
  • Why they ask this: Choosing where to store tokens and preferences affects both security and user experience.

    Answer

    CookieslocalStoragesessionStorage
    Sizeabout 4 KB eachabout 5 MBabout 5 MB
    Sent to the server automaticallyyes, with every matching requestnono
    Lifetimeuntil Expires/Max-Age, or the sessionuntil cleareduntil the tab closes
    Readable by JavaScriptunless HttpOnlyyesyes

    Security notes:

    • Store auth tokens in HttpOnly, Secure, SameSite cookies where possible, so an XSS attack cannot read them.
    • Anything in localStorage can be stolen by any script running on the page.
    • Use localStorage for non-sensitive preferences such as the theme or a saved filter.
    Open full page
  • Why they ask this: Every team uses Git; this checks you can collaborate without rewriting shared history.

    Answer

    Both bring changes from one branch into another:

    • git merge main creates a merge commit that joins the two histories. Nothing is rewritten, so it is safe on shared branches, but the history shows every merge.
    • git rebase main replays your branch's commits on top of main, creating new commits with new hashes. The result is a clean, linear history.
    bash
    git switch feature/login
    git fetch origin
    git rebase origin/main      # update your feature branch
    # fix conflicts, then: git add <file> && git rebase --continue
    git push --force-with-lease # needed because history changed

    Golden rule: never rebase commits that other people have already pulled (such as main). Rebase your own feature branch; merge into shared branches, usually through a pull request.

    Open full page
  • Why they ask this: A basic Git question that shows whether you understand remote-tracking branches.

    Answer

    • git fetch downloads new commits and branches from the remote and updates the remote-tracking branches (origin/main). It does not change your working files or your current branch.
    • git pull is git fetch followed by a merge (or a rebase, with git pull --rebase) into your current branch.
    bash
    git fetch origin
    git log --oneline main..origin/main   # see what is new before merging
    git pull --rebase origin main         # fetch and replay your commits on top

    Fetching first is safer when you want to review incoming changes before integrating them.

    Open full page
23456