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

46 questions

  • Why they ask this: Most users in Nepal browse on mobile phones, so responsive design is a must-have skill.

    Answer

    1. Add the viewport meta tag: <meta name="viewport" content="width=device-width, initial-scale=1">.
    2. Design mobile-first: write base styles for small screens, then add min-width media queries for larger ones.
    3. Use flexible layouts (Flexbox, Grid with fr and minmax()) and relative units (%, rem, vw) instead of fixed pixel widths.
    4. Make media fluid: img { max-width: 100%; height: auto; }, and use srcset for different image sizes.
    5. Test on real devices and in the browser DevTools device mode.
    css
    .grid { display: grid; gap: 1rem; }
    
    @media (min-width: 768px) {
      .grid { grid-template-columns: repeat(2, 1fr); }
    }
    Open full page
  • Why they ask this: Middleware is how cross-cutting concerns like auth are handled; it shows you understand the request lifecycle.

    Answer

    Middleware is a layer that every matching HTTP request passes through before it reaches the controller, and the response passes back through after. Each middleware can let the request continue ($next($request)), change it, or stop it early.

    Common uses:

    • Authentication: auth / auth:sanctum reject guests.
    • Authorisation and roles: for example only admins can reach /admin.
    • Rate limiting: throttle:60,1.
    • CORS, CSRF protection, logging, setting the locale.
    php
    class EnsureUserIsAdmin
    {
        public function handle(Request $request, Closure $next): Response
        {
            if (! $request->user()?->is_admin) {
                abort(403);
            }
    
            return $next($request);
        }
    }
    
    Route::middleware(['auth', EnsureUserIsAdmin::class])->group(function () {
        Route::get('/admin', AdminDashboardController::class);
    });
    Open full page
  • Why they ask this: Every team project uses migrations; this checks you can work safely with a shared database schema.

    Answer

    Migrations are version control for the database schema. Each migration is a PHP class with an up() method that makes a change and a down() method that reverses it.

    php
    Schema::create('jobs', function (Blueprint $table) {
        $table->id();
        $table->foreignId('company_id')->constrained()->cascadeOnDelete();
        $table->string('title');
        $table->unsignedInteger('salary_min')->nullable();
        $table->timestamps();
    });

    Useful commands: php artisan make:migration, migrate, migrate:rollback, migrate:status.

    Why they are useful:

    • Every developer and server gets the same schema by running php artisan migrate.
    • Changes are reviewed in Git like any other code.
    • Changes can be rolled back.

    Never edit a migration that has already run in production. Create a new one instead.

    Open full page
  • Why they ask this: Shows you understand the core of the framework and can write testable, loosely coupled code.

    Answer

    Dependency injection (DI) means a class receives the objects it needs (its dependencies) from outside, usually through the constructor, instead of creating them itself. This makes code easier to test and swap.

    The service container is Laravel's tool for building objects and their dependencies. It uses reflection on type hints to auto-resolve concrete classes, so this works with no configuration:

    php
    class InvoiceController
    {
        public function __construct(private InvoiceService $invoices) {}
    }

    For interfaces, you tell the container which implementation to use, usually in a service provider:

    php
    $this->app->bind(PaymentGateway::class, KhaltiGateway::class);
    $this->app->singleton(ExchangeRates::class, fn () => new ExchangeRates(config('services.nrb.url')));

    Benefits:

    • In tests you can replace an implementation with a fake: $this->app->instance(PaymentGateway::class, new FakeGateway).
    • Switching from eSewa to Khalti only changes one binding, not every class that uses the gateway.
    Open full page
  • Why they ask this: Security basics are non-negotiable for backend roles.

    Answer

    • SQL injection: the query builder and Eloquent use PDO parameter binding, so user input is never pasted into SQL. Stay safe with raw SQL by passing bindings: DB::select('select * from users where email = ?', [$email]). Never concatenate input into whereRaw.
    • XSS (cross-site scripting): Blade's {{ $value }} escapes output with htmlspecialchars. Only use {!! $value !!} for HTML you have sanitised.
    • CSRF (cross-site request forgery): web routes check a CSRF token on POST, PUT, PATCH and DELETE requests. Add @csrf inside Blade forms. Token-authenticated APIs (for example Sanctum tokens) are not exposed to CSRF in the same way.

    Also mention: mass assignment protection with $fillable, validation with Form Requests, hashing passwords with Hash::make (bcrypt or argon2), and authorisation with policies.

    Open full page
  • Why they ask this: Most Nepali startups build an API for a React or mobile frontend, so you must know which auth fits.

    Answer

    • Session-based: after login the server stores the session (in files, the database or Redis) and sends the browser a session cookie. Each request sends the cookie and the server looks up the session. This is stateful and works best for same-domain web apps. Protect it with CSRF tokens.
    • Token-based: after login the server returns a token that the client sends in the Authorization: Bearer <token> header. This suits mobile apps and third-party clients.
      • Opaque tokens (such as Laravel Sanctum personal access tokens) are stored in the database and are easy to revoke.
      • JWTs are signed and self-contained, so the server does not need a lookup, but they are harder to revoke before they expire.

    In Laravel, Sanctum handles both: cookie-based SPA authentication for your own frontend and API tokens for mobile apps. Never store tokens where scripts can read them (such as localStorage) if you can use an httpOnly cookie instead.

    Open full page
  • 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 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
1234