Why they ask this: Choosing where to store tokens and preferences affects both security and user experience.
Answer
| Cookies | localStorage | sessionStorage | |
|---|---|---|---|
| Size | about 4 KB each | about 5 MB | about 5 MB |
| Sent to the server automatically | yes, with every matching request | no | no |
| Lifetime | until Expires/Max-Age, or the session | until cleared | until the tab closes |
| Readable by JavaScript | unless HttpOnly | yes | yes |
Security notes:
HttpOnly, Secure, SameSite cookies where possible, so an XSS attack cannot read them.localStorage can be stolen by any script running on the page.localStorage for non-sensitive preferences such as the theme or a saved filter.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.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 changedGolden 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.
Why they ask this: A basic Git question that shows whether you understand remote-tracking branches.
Answer
Why they ask this: Conflicts happen weekly in team projects; interviewers want to see you stay calm and methodical.
Answer
Why they ask this: Your GitHub history is often the first code a Nepali recruiter or tech lead looks at.
Answer
Why they ask this: Asked in almost every fresher interview in Nepal; a clear answer with examples stands out.
Answer
Why they ask this: Tests whether you can design flexible code rather than only reciting definitions.
Answer
Why they ask this: Mid-level and good junior candidates are expected to know how to keep code maintainable.
Answer
git fetch downloads new commits and branches from the remote and updates the remote-tracking branches (origin/main). It does not change your working files or your current branch.git pull is git fetch followed by a merge (or a rebase, with git pull --rebase) into your current branch.git fetch origin
git log --oneline main..origin/main # see what is new before merging
git pull --rebase origin main # fetch and replay your commits on topFetching first is safer when you want to review incoming changes before integrating them.
A conflict happens when two branches change the same lines of a file (or one deletes a file the other edits), so Git cannot combine them automatically.
git status to see the conflicted files.<<<<<<< HEAD
const API_URL = '/api/v1';
=======
const API_URL = '/api/v2';
>>>>>>> feature/new-apigit add <file>, then git commit (for a merge) or git rebase --continue (for a rebase).To give up and start again, use git merge --abort or git rebase --abort. VS Code's merge editor makes the "accept current / incoming / both" choice easier.
Good commits:
Add password reset email. Add a body explaining why when it is not obvious.feat: add job filters, fix: handle empty salary, docs: update README..env), node_modules or vendor. Use .gitignore.A simple branching workflow (GitHub flow):
main always deployable.feature/job-search, fix/login-redirect.Larger teams may add a develop branch or release branches (Git Flow), but GitHub flow is enough for most projects.
private properties, public methods).PaymentGateway interface with a charge() method.class Admin extends User).interface PaymentGateway
{
public function charge(int $amountInPaisa): bool;
}
final class EsewaGateway implements PaymentGateway
{
public function charge(int $amountInPaisa): bool { /* call eSewa */ return true; }
}
final class KhaltiGateway implements PaymentGateway
{
public function charge(int $amountInPaisa): bool { /* call Khalti */ return true; }
}
function checkout(PaymentGateway $gateway): void
{
$gateway->charge(150000); // polymorphism: works with either gateway
}| Interface | Abstract class | |
|---|---|---|
| Contains | method signatures (and constants) | abstract and implemented methods, plus properties |
| A class can use | many interfaces | only one parent class (in PHP, Java and Dart) |
| Constructor and state | no | yes |
| Meaning | "can do" (a capability) | "is a" (a shared base) |
Cacheable, PaymentGateway.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.
KhaltiGateway class instead of adding another if to existing code.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.