Multiple choice practice

DevOps MCQ questions

Take a short practice test with instant feedback, then revise every question with its answer and the reason behind it.

Questions
50
From lessons
30
Your last test
—

Practice test

DevOps practice testMultiple choice Question 1 of 10

What does “build once, deploy many” mean?

Score so far: 0/0

All questions with answers

  1. Which command creates a local copy of a remote repository?

    • Agit init
    • Bgit clone
    • Cgit pull
    • Dgit fork
    Show answer

    Answer: B. git clone

    clone copies the repository with its full history.

  2. Which command stages changes for the next commit?

    • Agit commit
    • Bgit add
    • Cgit push
    • Dgit stage-all
    Show answer

    Answer: B. git add

    git add moves changes into the index.

  3. Which command shows changed and staged files?

    • Agit log
    • Bgit status
    • Cgit diff --stat only
    • Dgit show
    Show answer

    Answer: B. git status

    git status summarises the working tree and index.

  4. Which command uploads local commits to the remote?

    • Agit fetch
    • Bgit push
    • Cgit merge
    • Dgit sync
    Show answer

    Answer: B. git push

    push sends commits; fetch downloads them.

  5. Which practice integrates code to the main branch several times a day with automated builds?

    • AContinuous integration
    • BContinuous deployment
    • CWaterfall
    • DRelease trains
    Show answer

    Answer: A. Continuous integration

    CI catches integration problems early.

  6. Where do GitHub Actions workflows live?

    • A.github/actions
    • B.github/workflows
    • C.ci/
    • Dworkflows/ at the root
    Show answer

    Answer: B. .github/workflows

    Each YAML file in .github/workflows is a workflow.

  7. Which keyword makes a job wait for another job?

    • Aafter
    • Bdepends
    • Cneeds
    • Dwait
    Show answer

    Answer: C. needs

    needs: build runs the job after build succeeds.

  8. Which Dockerfile instruction sets the command a container runs?

    • ARUN
    • BCMD / ENTRYPOINT
    • CFROM
    • DEXPOSE
    Show answer

    Answer: B. CMD / ENTRYPOINT

    RUN executes at build time; CMD and ENTRYPOINT at container start.

  9. What does a multi-stage build reduce?

    • ABuild time only
    • BFinal image size and attack surface
    • CNumber of containers
    • DNetwork latency
    Show answer

    Answer: B. Final image size and attack surface

    Build tools stay in earlier stages and are not shipped.

  10. Which command lists running containers?

    • Adocker images
    • Bdocker ps
    • Cdocker run
    • Ddocker list
    Show answer

    Answer: B. docker ps

    docker ps -a also shows stopped containers.

  11. Which file defines multi-container apps for Docker Compose?

    • ADockerfile
    • Bcompose.yaml
    • Cdocker.json
    • Dk8s.yaml
    Show answer

    Answer: B. compose.yaml

    docker compose up starts all the services it defines.

  12. What is the smallest deployable unit in Kubernetes?

    • AContainer
    • BPod
    • CNode
    • DDeployment
    Show answer

    Answer: B. Pod

    A Pod wraps one or more containers that share network and storage.

  13. Which Kubernetes object gives Pods a stable network address?

    • AConfigMap
    • BService
    • CSecret
    • DNamespace
    Show answer

    Answer: B. Service

    Services load-balance across matching Pods.

  14. Which command shows a Terraform execution plan without changing anything?

    • Aterraform apply
    • Bterraform plan
    • Cterraform init
    • Dterraform show
    Show answer

    Answer: B. terraform plan

    Review the plan, then apply it.

  15. Which strategy sends a small percentage of traffic to a new version first?

    • ABlue-green
    • BCanary
    • CRecreate
    • DBig bang
    Show answer

    Answer: B. Canary

    Canary releases expand gradually while metrics stay healthy.

  16. Where should pipeline secrets be stored?

    • AIn the YAML file
    • BIn the repository README
    • CIn the platform’s secret store or a vault
    • DIn the Docker image
    Show answer

    Answer: C. In the platform’s secret store or a vault

    Secrets are injected at runtime and masked in logs.

  17. What is wrong with this workflow step?

    YAML Illustrative
    - run: curl -H "Authorization: Bearer ghp_EXAMPLE_NOT_A_REAL_TOKEN" https://deploy.example.com/release
    
    • ANothing
    • BThe token is hard-coded in the repository
    • Crun cannot call curl
    • DSteps need a name
    Show answer

    Answer: B. The token is hard-coded in the repository

    Use ${{ secrets.DEPLOY_TOKEN }} and rotate the exposed token immediately.

  18. Which kind of scan finds known vulnerabilities in dependencies?

    • ASAST
    • BSCA (software composition analysis)
    • CDAST
    • DLoad testing
    Show answer

    Answer: B. SCA (software composition analysis)

    Dependabot and npm audit are SCA tools.

  19. What does git rebase main do on a feature branch?

    • ADeletes main
    • BReplays the branch’s commits on top of main
    • CCreates a merge commit
    • DPushes to main
    Show answer

    Answer: B. Replays the branch’s commits on top of main

    It rewrites the branch’s commit hashes, so avoid it on shared branches.

  20. Which metric shows how often a team deploys to production?

    • ALead time
    • BDeployment frequency
    • CMTTR
    • DChange failure rate
    Show answer

    Answer: B. Deployment frequency

    It is one of the four DORA metrics.

  21. What is the relationship between an image and a container?

    • AThey are the same thing
    • BA container is a running instance of an image
    • CAn image is a running container
    • DImages run inside containers
    Show answer

    Answer: B. A container is a running instance of an image

    Images are templates; containers are running (or stopped) instances.

    From the lesson: Docker
  22. Which is NOT one of the four DORA metrics?

    • ADeployment frequency
    • BLines of code written
    • CChange failure rate
    • DTime to restore service
    Show answer

    Answer: B. Lines of code written

    Lines of code is not a DORA metric.

    From the lesson: Introduction to DevOps
  23. What does “shift left” mean?

    • AMove servers left
    • BTest and check security earlier in the lifecycle
    • CDeploy on Mondays
    • DWrite code right to left
    Show answer

    Answer: B. Test and check security earlier in the lifecycle

    Earlier checks catch problems when they are cheap to fix.

    From the lesson: Software Development Lifecycle
  24. Which command moves changes into the staging area?

    • Agit commit
    • Bgit add
    • Cgit push
    • Dgit log
    Show answer

    Answer: B. git add

    git add stages changes for the next commit.

    From the lesson: Git Fundamentals
  25. What does git push -u origin main do the first time?

    • ADeletes main
    • BPushes main and sets it to track origin/main
    • CCreates a new repo
    • DPulls changes
    Show answer

    Answer: B. Pushes main and sets it to track origin/main

    -u sets the upstream branch.

    From the lesson: GitHub