Software Development Practices MCQs for the NSCT

By the NSCT Exam Editorial Team · Updated 2026-11-24 · Facts checked against official sources on 2026-11-24

Software development practices are the everyday habits that keep code working when a team changes it: version control with Git, clean and readable code, useful documentation, and code review. It is topic 16, the last of the 16 in the Programming (C++/Java/Python) area, which carries 10% of the NSCT according to HEC's Areas of Competencies. Candidates averaged 47.8% accuracy in this area in 2026, per the HEC NSCT report.

These questions reward practical experience. If you used Git for your FYP, you already know half the answers. The process side (SDLC models, agile, CI/CD pipelines) is covered in more depth under Software Engineering.

Git

Git is a distributed version control system: every clone holds the full history. Files move through three areas, the working directory, the staging area (index) and the repository. git add stages a snapshot, and git commit records whatever is staged.

Command What it does
git status --short Shows ?? for untracked, A for added and M for modified files
git switch -c feature Creates a branch and switches to it (git checkout -b is the older form)
git merge feature Fast-forwards if possible, otherwise creates a merge commit
git pull git fetch plus git merge (or a rebase, if configured)
git revert <commit> Adds a new commit that undoes it; safe on shared branches
git reset --soft/--mixed/--hard Moves the branch back; keeps changes staged, unstaged or discards them
git stash Shelves uncommitted changes so the working tree is clean
git cherry-pick <commit> Copies one commit onto the current branch with a new hash

When both branches change the same line, a merge stops with conflict markers:

<<<<<<< HEAD
color = green
=======
color = blue
>>>>>>> feature

Exam angle: questions often ask what is in a commit after a file was edited again after git add. The answer is the staged version, not the latest edit. Also remember that .gitignore has no effect on files that are already tracked.

Clean code

Clean code is code that another person can read, change and test easily. The principles that come up most often are:

Principle Meaning
Meaningful names days_since_borrowed, not d
DRY Don't Repeat Yourself: one place for each piece of logic
KISS Keep It Simple: prefer the plainest working design
YAGNI You Aren't Gonna Need It: no speculative features
SRP Single Responsibility: one reason for a class to change
No magic numbers SECONDS_PER_DAY = 86400, not a bare 86400

Naming conventions differ by language. Python's PEP 8 uses snake_case for functions and variables. Java uses camelCase for methods and variables. Both use PascalCase for classes and UPPER_SNAKE_CASE for constants. A code smell such as a long method, duplicated code or a long boolean parameter list signals that the code needs refactoring: restructuring it without changing its behaviour.

Exam angle: a class with calculate(), print_pdf() and save_to_db() is the classic SRP violation.

Documentation

Documentation explains the code to its users and maintainers. It works at several levels: - Docstrings and Javadoc describe what a function does, its parameters and its return value. - Comments explain why the code does something non-obvious. - README files explain how to install, run and use a project.

def area(r):
    """Return the area of a circle of radius r."""
    return 3.14159 * r * r

print(area.__doc__)   # Return the area of a circle of radius r.

A comment that only restates the code adds noise. A comment that contradicts the code, such as # 10% discount above price * 0.85, is worse than none. Semantic versioning (MAJOR.MINOR.PATCH) also documents changes: a breaking change moves 2.4.1 to 3.0.0, a new compatible feature moves 1.9.3 to 1.10.0, and a bug fix moves 1.9.3 to 1.9.4.

Exam angle: expect a "what does a good comment explain?" question. The answer is the why, not the what.

Code review

In a code review, another developer reads a change, usually as a pull request, before it is merged. Its goals are to: - catch defects and security issues early, when they are cheapest to fix; - keep the code consistent with team standards; - spread knowledge of the codebase across the team.

Good review comments are specific and about the code, not the person. They also come with a reason, for example: "process(data, True, False) is hard to read; use keyword arguments." Reviews complement automated tests and continuous integration (CI), which builds and tests every change automatically. They do not replace them.

Exam angle: the purpose of a review is quality and shared knowledge, not counting lines or blaming the author.

Common traps

Worked examples

1. Understanding. What is the difference between forking and cloning a repository? Answer: a clone is a full local copy of a repository on your machine. A fork is a server-side copy made on a hosting platform such as GitHub, under your own account. You usually fork a project you cannot push to, clone your fork, and then open pull requests back to the original.

2. Application. In a repository with commits A and B, you run git reset --hard HEAD~1. How many commits does git log --oneline show, and what happens to B's changes? Answer: one commit (A). --hard moves the branch back and also resets the staging area and working files, so B's changes disappear from the files. Until garbage collection, git reflog can still find B.

3. Analysis. In a pull request, a method named getStudents() returns the list of students and also deletes records older than five years. What should the reviewer flag? Answer: a hidden side effect. The name promises a read-only query, so callers will not expect data to be deleted. Split it into getStudents() and purgeOldRecords(). This is command-query separation, and it also follows SRP.

Practise

The quiz below has 99 questions on software development practices, filterable by tier and difficulty.

Practise: 99 questions

Interactive quiz loading. The first 10 questions are shown below.

  1. Which Git command moves changes from the working directory into the staging area (the index)?

    1. git commit
    2. git push
    3. git add
    4. git init
    Show answer

    Answer: C. git add

    git add stages a snapshot of the named files, so the next commit will include them. git commit records what is staged, git push uploads commits to a remote, and git init creates a new repository.

  2. What is the main purpose of a version control system such as Git?

    1. To record the history of changes so you can compare, restore and merge versions of code
    2. To compile code faster
    3. To find bugs automatically
    4. To host websites
    Show answer

    Answer: A. To record the history of changes so you can compare, restore and merge versions of code

    Version control records every committed change with its author and message. That lets you see who changed what, roll back mistakes, work on branches in parallel and merge everyone's work. It does not compile or debug code.

  3. By default, what does git pull do?

    1. Fetches new commits from the remote and merges them into the current branch
    2. Uploads local commits to the remote
    3. Only downloads commits without changing any local branch
    4. Deletes local changes and copies the remote branch
    Show answer

    Answer: A. Fetches new commits from the remote and merges them into the current branch

    git pull is git fetch followed by git merge (or a rebase, if configured). git fetch alone downloads commits without touching your branch, and git push uploads your commits.

  4. How does git revert differ from git reset when undoing a commit?

    1. revert adds a new commit that undoes the change; reset moves the branch pointer back, removing commits from the branch
    2. revert deletes the commit permanently; reset keeps it
    3. They are identical commands with different names
    4. revert works only on unpushed commits; reset works only on pushed ones
    Show answer

    Answer: A. revert adds a new commit that undoes the change; reset moves the branch pointer back, removing commits from the branch

    git revert keeps history intact by adding an inverse commit, so it is safe on shared branches. git reset rewrites the branch so it points at an earlier commit, which is fine locally but disrupts anyone who already pulled the removed commits.

  5. What does the DRY principle stand for?

    1. Do Repeat Yourself
    2. Debug, Refactor, Yield
    3. Document Rarely, Yearly
    4. Don't Repeat Yourself
    Show answer

    Answer: D. Don't Repeat Yourself

    DRY (from The Pragmatic Programmer) says each piece of knowledge should have a single representation in a system. Duplicated logic means a fix must be applied in several places, and one is usually missed.

  6. What does the YAGNI principle advise?

    1. Always add extension points for possible future needs
    2. Write all documentation before any code
    3. Never delete unused code
    4. Don't build features until they are actually needed
    Show answer

    Answer: D. Don't build features until they are actually needed

    YAGNI ('You Aren't Gonna Need It') comes from Extreme Programming. Speculative features add code to test and maintain, and often turn out to be wrong when the real need arrives. Build for today's requirements and keep the code easy to change.

  7. According to PEP 8, how should a Python function that calculates total marks be named?

    1. CalculateTotalMarks
    2. calculate_total_marks
    3. calculateTotalMarks
    4. CALCULATE_TOTAL_MARKS
    Show answer

    Answer: B. calculate_total_marks

    PEP 8 uses snake_case (lowercase with underscores) for functions and variables, CapWords (PascalCase) for classes and UPPER_CASE for constants. camelCase is the Java convention for methods.

  8. Which name follows standard Java naming conventions for a constant?

    1. maxStudents
    2. MaxStudents
    3. max_students
    4. MAX_STUDENTS
    Show answer

    Answer: D. MAX_STUDENTS

    Java constants (static final fields) use UPPER_SNAKE_CASE. Classes use PascalCase (StudentRecord), and methods and variables use camelCase (maxStudents). snake_case is not the Java convention.

  9. In clean-code terms, what is a 'magic number'?

    1. A random number produced by a secure generator
    2. An unexplained literal value in code, such as 86400, whose meaning is not obvious
    3. A number that the compiler optimises away
    4. A constant declared with a descriptive name
    Show answer

    Answer: B. An unexplained literal value in code, such as 86400, whose meaning is not obvious

    A magic number is a bare literal whose purpose the reader must guess. Replacing it with a named constant, such as SECONDS_PER_DAY = 86400, documents its meaning and gives one place to change it.

  10. What is a Python docstring?

    1. Any comment that starts with #
    2. A separate .txt file stored next to the module
    3. A string literal written as the first statement of a module, class or function, available through __doc__ and help()
    4. A string that the interpreter executes as code
    Show answer

    Answer: C. A string literal written as the first statement of a module, class or function, available through __doc__ and help()

    A docstring is a triple-quoted string placed first in a module, class or function body. Python stores it in the object's __doc__ attribute, so help() and documentation tools can show it. Comments starting with # are discarded and are not docstrings.

FAQs

What is the difference between git merge and git rebase?

Merge joins two branches and keeps both histories, adding a merge commit when they have diverged. Rebase replays your commits on top of the other branch, giving a straight history but creating new commits with new hashes. Use rebase only on your own unpublished branches, and merge on shared ones.

What is the difference between git fetch and git pull?

git fetch downloads new commits and updates remote-tracking branches such as origin/main, but leaves your own branch and files untouched. git pull runs a fetch and then merges (or rebases) those commits into your current branch. Fetching first lets you inspect the changes before integrating them.

Do I need to memorise Git commands for the NSCT?

HEC lists software development practices as a topic but does not publish a command list. Know the core workflow well: init, add, commit, status, branch, switch, merge, pull, push, revert and reset. Understand what each one does to the working directory, the staging area and the history, rather than memorising flags.

Next step

You have reached the last Programming topic. Consolidate with the Programming revision notes, revisit the Programming MCQs hub, or test yourself in an NSCT mock test.