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

12 questions

  • Why they ask this: Closures power callbacks, React hooks, module patterns and data privacy, so they show how well you know the language.

    Answer

    A closure is a function together with the variables from the scope where it was created. The inner function keeps access to those variables even after the outer function has returned.

    js
    function makeCounter() {
      let count = 0; // private to the closure
      return {
        increment: () => ++count,
        current: () => count,
      };
    }
    
    const counter = makeCounter();
    counter.increment();
    counter.increment();
    console.log(counter.current()); // 2

    Practical uses:

    • Data privacy: count cannot be changed from outside.
    • Function factories, for example const add5 = makeAdder(5).
    • Callbacks and event handlers that remember values.
    • React hooks: every render's handlers close over that render's state, which is why stale state bugs happen.
    Open full page
  • Why they ask this: Shows whether you understand how async code actually runs, which matters for debugging ordering and UI freezes.

    Answer

    JavaScript runs your code on one thread with a call stack. Async work (timers, network, DOM events) is handled by the browser or Node.js, and their callbacks are queued.

    The event loop repeats:

    1. Run the current script until the call stack is empty.
    2. Run all microtasks: promise callbacks (.then, await continuations) and queueMicrotask.
    3. Let the browser render if needed.
    4. Take one macrotask (task) such as a setTimeout callback or an event handler, run it, and go back to step 2.
    js
    console.log('1');
    setTimeout(() => console.log('2'), 0);
    Promise.resolve().then(() => console.log('3'));
    console.log('4');
    // Output: 1, 4, 3, 2

    Microtasks always run before the next timer, even a 0 ms one. A long synchronous loop blocks everything, including clicks and rendering.

    Open full page
  • Why they ask this: Almost every app calls APIs; interviewers check you can write and handle async code correctly.

    Answer

    A Promise represents a value that will be available later (pending, then fulfilled or rejected). async/await is syntax on top of promises that makes async code read like synchronous code.

    js
    // Promise chain
    fetch('/api/jobs')
      .then((res) => res.json())
      .then((jobs) => console.log(jobs))
      .catch((err) => console.error(err));
    
    // async/await
    async function loadJobs() {
      try {
        const res = await fetch('/api/jobs');
        if (!res.ok) throw new Error(`HTTP ${res.status}`);
        return await res.json();
      } catch (err) {
        console.error(err);
      }
    }

    Points worth mentioning:

    • An async function always returns a promise.
    • Use try/catch for errors with await.
    • Run independent requests in parallel with await Promise.all([...]) instead of awaiting one after another.
    Open full page
  • Why they ask this: Most React bugs (infinite loops, stale data, memory leaks) come from misusing useEffect.

    Answer

    useEffect(effect, deps) runs effect after render:

    • No array: runs after every render.
    • []: runs once after the first render (mount).
    • [a, b]: runs after the first render and again whenever a or b changes (compared with Object.is).

    The function you return is the cleanup. It runs before the effect runs again and when the component unmounts. Use it to remove listeners, clear timers and cancel requests.

    jsx
    useEffect(() => {
      const controller = new AbortController();
      fetch(`/api/jobs?q=${query}`, { signal: controller.signal })
        .then((r) => r.json())
        .then(setJobs)
        .catch(() => {});
      return () => controller.abort(); // cancel the old request when query changes
    }, [query]);

    Include every value from the component that the effect uses in the array. Missing dependencies cause stale values.

    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: 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
  • Why they ask this: There is no single right answer; interviewers want reasoning, not a favourite library.

    Answer

    • setState: local state inside one widget. Simple and perfectly fine for small screens.
    • InheritedWidget / ValueNotifier + ValueListenableBuilder: built into Flutter and lightweight.
    • Provider: wraps InheritedWidget. Good for simple app-wide state, such as the logged-in user or the theme.
    • Riverpod: a compile-safe evolution of Provider that does not depend on BuildContext. Good for async data and testing.
    • Bloc / Cubit: events and states in streams, with a strict separation between UI and logic. Popular in larger teams.
    • GetX: concise, but often criticised for mixing concerns.

    How to choose: keep state as local as possible. Pick a shared solution when several screens need the same data. Consider the team's experience, how testable it is, and how much boilerplate you can accept. Be ready to explain one approach in depth with code from a project you built.

    Open full page
  • Why they ask this: Misusing BuildContext causes common runtime errors, so this tests deeper Flutter knowledge.

    Answer

    A BuildContext is a handle to a widget's location in the widget tree (it is actually the widget's Element). It is used to look up the tree for inherited data and services:

    text
    final theme = Theme.of(context);
    final size = MediaQuery.sizeOf(context);
    Navigator.of(context).push(MaterialPageRoute(builder: (_) => const JobScreen()));
    ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('Saved')));

    Common pitfalls:

    • Scaffold.of(context) fails if context belongs to a widget above the Scaffold. Wrap the child in a Builder to get a context below it.
    • After an await, the widget may have been removed. Check if (!context.mounted) return; before using the context again.
    Open full page
  • Why they ask this: Networking, databases and real-time features in Flutter depend on async Dart.

    Answer

    • A Future<T> delivers one value (or an error) later, such as an HTTP response. Use it with async/await or FutureBuilder.
    • A Stream<T> delivers many values over time, such as location updates, Firestore snapshots, WebSocket messages or user input. Use it with await for, listen() or StreamBuilder.
    text
    Future<List<Job>> fetchJobs() async {
      final res = await http.get(Uri.parse('https://api.example.com/jobs'));
      if (res.statusCode != 200) throw Exception('Failed: ${res.statusCode}');
      return (jsonDecode(res.body) as List).map((j) => Job.fromJson(j)).toList();
    }
    
    Stream<int> countdown(int from) async* {
      for (var i = from; i >= 0; i--) {
        await Future.delayed(const Duration(seconds: 1));
        yield i;
      }
    }

    Always cancel stream subscriptions in dispose() to avoid memory leaks.

    Open full page
  • Why they ask this: Offline support and secure token storage come up in nearly every mobile project.

    Answer

    Choose storage by what you are saving:

    • AsyncStorage (@react-native-async-storage/async-storage): simple, unencrypted key-value storage for small, non-sensitive data such as settings or onboarding flags.
    • MMKV (react-native-mmkv): a much faster key-value store, also synchronous.
    • Secure storage for tokens and secrets: expo-secure-store or react-native-keychain, which use the iOS Keychain and the Android Keystore.
    • A database for larger, structured or offline-first data: SQLite (expo-sqlite), WatermelonDB or Realm.
    js
    import * as SecureStore from 'expo-secure-store';
    
    await SecureStore.setItemAsync('auth_token', token);
    const saved = await SecureStore.getItemAsync('auth_token');

    Never put access tokens in AsyncStorage, and never ship API secrets inside the app bundle, because the bundle can be unpacked.

    Open full page
  • Why they ask this: Shows practical debugging experience beyond building happy-path screens.

    Answer

    Measure first:

    • Turn on the Perf Monitor in the dev menu to watch JS and UI frame rates.
    • Use React DevTools Profiler to find components that re-render too often.
    • Use Android Studio and Xcode profilers for memory and native issues.
    • Always test a release build on a real, low-end Android phone, which is what many users in Nepal have.

    Common fixes:

    • Use FlatList (or FlashList) with stable keys instead of mapping long arrays in a ScrollView.
    • Avoid unnecessary re-renders with React.memo, useCallback and useMemo, and keep state close to where it is used.
    • Resize and cache images, for example with expo-image.
    • Run animations on the UI thread with Reanimated, or useNativeDriver: true.
    • Move heavy work off the JS thread and remove console.log calls from release builds.
    • Make sure the Hermes engine is enabled (the default in current versions).
    Open full page