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

14 questions

12
  • Why they ask this: The most common Eloquent performance bug; it shows you think about the queries your code runs.

    Answer

    The N+1 problem happens when you load a list (1 query) and then run one more query per item to load a relationship (N queries).

    php
    // 1 query for posts + 1 query per post for its author = N+1
    $posts = Post::all();
    foreach ($posts as $post) {
        echo $post->author->name;
    }

    Fix it with eager loading, which loads the relationship for all rows in one extra query:

    php
    Open full page
  • Why they ask this: An open-ended classic that shows how broad your understanding of the web is.

    Answer

    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

    Open full page
  • Why they ask this: Security basics are non-negotiable for backend roles.

    Answer

    Open full page
  • Why they ask this: Shows you know how to keep web requests fast and handle slow work reliably.

    Answer

    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

    Open full page
  • Why they ask this: Indexes are the first tool for slow queries; this checks real-world database thinking.

    Answer

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

    Answer

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

    Answer

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

    Answer

    Open full page
  • Why they ask this: Every team uses Git; this checks you can collaborate without rewriting shared history.

    Answer

    Open full page
  • Why they ask this: Tests whether you can design flexible code rather than only reciting definitions.

    Answer

    Open full page
$posts = Post::with('author')->get();           // 2 queries in total
$posts = Post::with(['author', 'comments'])->get();
$count = Post::withCount('comments')->get();     // comments_count without loading them

Find N+1 problems with Laravel Debugbar or Telescope, or make them fail loudly in development with Model::preventLazyLoading(! app()->isProduction());.

  1. URL parsing: the browser works out the scheme (https), host and path.
  2. DNS lookup: the hostname is resolved to an IP address (browser cache → OS cache → resolver → root, TLD and authoritative name servers).
  3. TCP connection to the server on port 443 (a three-way handshake). HTTP/3 uses QUIC over UDP instead.
  4. TLS handshake: the server proves its identity with a certificate and both sides agree on encryption keys.
  5. HTTP request: for example GET /jobs with headers and cookies.
  6. Server side: a load balancer or web server (Nginx) passes the request to the app (Laravel or Node), which may query the database and returns a response, often via a CDN cache.
  7. Rendering: the browser parses HTML into the DOM and CSS into the CSSOM, runs JavaScript, builds the render tree, then does layout and paint.
  8. Extra requests load images, scripts and fonts, and caching headers decide what is reused next time.

Go deeper on whichever part matches the role you are applying for.

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);
});
  • 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.

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.

  • 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.

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.

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.

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.

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.

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.

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.