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

29 questions

  • 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: 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: Shows you know how to keep web requests fast and handle slow work reliably.

    Answer

    A job is a class that does one piece of work. A queue stores jobs so that a separate worker process (php artisan queue:work) runs them in the background.

    Use queues for anything slow or unreliable that the user should not wait for:

    • sending emails and SMS,
    • generating PDFs or resizing images,
    • calling third-party APIs (payment verification, AI),
    • importing large CSV files.
    php
    class SendWelcomeEmail implements ShouldQueue
    {
        use Queueable;
    
        public int $tries = 3;
    
        public function __construct(public User $user) {}
    
        public function handle(): void
        {
            Mail::to($this->user)->send(new WelcomeMail($this->user));
        }
    }
    
    SendWelcomeEmail::dispatch($user);

    Queue drivers include database, redis and Amazon SQS. Failed jobs are stored and can be retried with php artisan queue:retry. In production, keep the worker running with Supervisor (or a platform's worker process) and restart it after each deploy.

    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: 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: 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 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: 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: Tests whether you can design flexible code rather than only reciting definitions.

    Answer

    InterfaceAbstract class
    Containsmethod signatures (and constants)abstract and implemented methods, plus properties
    A class can usemany interfacesonly one parent class (in PHP, Java and Dart)
    Constructor and statenoyes
    Meaning"can do" (a capability)"is a" (a shared base)
    • Use an interface to define a contract that unrelated classes can implement: Cacheable, PaymentGateway.
    • Use an abstract class to share code between closely related classes that differ in a few steps, for example a Report base class with an abstract rows() method.

    In PHP you can combine both, and use traits to share code horizontally. Dart has no interface keyword in older versions: every class can be implemented with implements, and Dart 3 adds interface class.

    Open full page
  • Why they ask this: Mid-level and good junior candidates are expected to know how to keep code maintainable.

    Answer

    • S, Single Responsibility: a class should have one reason to change. Do not mix validation, payment and email sending in one class.
    • O, Open/Closed: open for extension, closed for modification. Add a new KhaltiGateway class instead of adding another if to existing code.
    • L, Liskov Substitution: a subclass must work anywhere its parent is expected, without surprising behaviour.
    • I, Interface Segregation: prefer several small interfaces over one large one, so classes do not implement methods they do not need.
    • D, Dependency Inversion: depend on abstractions (interfaces), not concrete classes, and inject them, for example through Laravel's service container.

    Do not just recite the list: give one real example from your own project of a principle you applied, or one you broke and later fixed.

    Open full page
  • Why they ask this: Checks design maturity; deep inheritance trees are a common source of rigid code.

    Answer

    • Inheritance ("is a") ties a child class tightly to its parent. A change in the parent can break every child, and deep hierarchies become hard to change.
    • Composition ("has a") builds behaviour by holding other objects and delegating to them. Parts can be swapped, tested alone and combined freely.
    php
    // Inheritance: every new notification channel needs a new subclass
    class SmsOrderNotifier extends OrderNotifier { /* ... */ }
    
    // Composition: inject the channel
    final class OrderNotifier
    {
        public function __construct(private NotificationChannel $channel) {}
    
        public function notify(Order $order): void
        {
            $this->channel->send($order->customer, "Order #{$order->id} confirmed");
        }
    }

    Inheritance is still fine for a true, stable "is a" relationship with shared behaviour. Flutter is a good example of composition: UIs are built by nesting small widgets rather than extending big ones.

    Open full page
123