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: Checks you can choose the right layout tool instead of fighting CSS.

    Answer

    • Flexbox is one-dimensional: it lays items out in a row or a column. It is great for navbars, toolbars, centring, and spacing items whose size comes from their content.
    • Grid is two-dimensional: rows and columns together. It is great for page layouts, card galleries and dashboards.
    css
    /* Flexbox: navbar */
    .nav { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
    
    /* Grid: responsive cards */
    .cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }

    They work well together, for example a Grid page layout with Flexbox inside each card.

    Open full page
  • Why they ask this: Explains "why is my style not applying?" problems that every frontend developer hits.

    Answer

    When several rules target the same element, the browser picks the one with the highest specificity. If specificity is equal, the rule that appears later wins.

    Specificity is compared as (IDs, classes/attributes/pseudo-classes, elements/pseudo-elements):

    SelectorSpecificity
    p(0, 0, 1)
    .card p(0, 1, 1)
    #main .card p(1, 1, 1)
    inline style=""beats any selector
    !importantoverrides normal declarations; avoid it

    :where() adds zero specificity, while :is() and :not() take the specificity of their most specific argument.

    Keep specificity low and flat (for example single classes with a BEM-style or utility approach) so styles stay easy to override.

    Open full page
  • Why they ask this: Positioning is needed for dropdowns, modals and sticky headers.

    Answer

    • static (default): normal document flow. top/left have no effect.
    • relative: stays in the flow, but can be nudged with top/left. It also becomes the containing block for absolutely positioned children.
    • absolute: removed from the flow and positioned relative to the nearest positioned ancestor (any value other than static), or the initial containing block if there is none.
    • fixed: removed from the flow and positioned relative to the viewport, so it stays put while scrolling. Note that a transform on an ancestor changes this.
    • sticky: acts like relative until a scroll threshold (such as top: 0) is reached, then sticks within its parent.
    css
    .dropdown-wrapper { position: relative; }
    .dropdown-menu { position: absolute; top: 100%; left: 0; }
    .site-header { position: sticky; top: 0; }
    Open full page
  • 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: Accessibility is increasingly expected; it shows care for all users and code quality.

    Answer

    • Use semantic elements (<button>, <nav>, <main>, headings in order) before reaching for ARIA.
    • Give images meaningful alt text (alt="" for decorative images).
    • Connect every form field to a <label> (for/id, or wrap the input).
    • Make everything usable with the keyboard: a logical tab order and a visible :focus-visible style.
    • Keep enough colour contrast: at least 4.5:1 for normal text (WCAG AA).
    • Use ARIA only to fill gaps, for example aria-expanded on a menu toggle or aria-live for status messages.

    Check your work with Lighthouse or axe DevTools and by navigating with only the keyboard.

    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: 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: Checks that your PHP knowledge is current and not stuck in PHP 5-era habits.

    Answer

    • Typed properties, union types and return types: public function find(int $id): ?User.
    • Constructor property promotion: public function __construct(private UserRepository $users) {}.
    • Named arguments: str_pad(string: $code, length: 6, pad_string: '0', pad_type: STR_PAD_LEFT).
    • match expression: strict comparison and returns a value, unlike switch.
    • Nullsafe operator: $user?->profile?->phone.
    • Enums (8.1): enum Status: string { case Active = 'active'; }.
    • readonly properties (8.1) and readonly classes (8.2) for immutable value objects and DTOs.
    • First-class callable syntax (8.1): array_map($this->format(...), $rows).
    • Property hooks (8.4): get/set logic declared on a property.
    php
    enum JobType: string
    {
        case FullTime = 'full_time';
        case Internship = 'internship';
    
        public function label(): string
        {
            return match ($this) {
                self::FullTime => 'Full time',
                self::Internship => 'Internship',
            };
        }
    }
    Open full page
12345