Certified Associate Programmer (CPA) Exam ā Questions and Answers
Question 1: A project manager is using a fishbone (Ishikawa) diagram. What is its primary purpose?
- To identify root causes of a problem or defect (Correct answer)
- To prioritize the product backlog
- To map task dependencies in a network diagram
- To track project milestones on a timeline
Correct answer: To identify root causes of a problem or defect
The fishbone diagram is a cause-and-effect tool used in quality management to identify potential root causes contributing to a specific problem.
Question 2: In Git, what does the `git pull` command do?
- Reverts the last local commit
- Pushes local commits to the remote
- Creates a new branch from the remote
- Fetches remote changes and merges them into the current local branch (Correct answer)
Correct answer: Fetches remote changes and merges them into the current local branch
git pull is a combination of git fetch (downloading remote changes) and git merge (integrating them into the local branch).
Question 3: What is the purpose of a flowchart in programming?
- To visually represent the steps and logic of an algorithm (Correct answer)
- To compile code faster
- To allocate memory for variables
- To define class hierarchies
Correct answer: To visually represent the steps and logic of an algorithm
A flowchart uses standardized symbols to graphically depict the flow of logic and decision-making steps in an algorithm.
Question 4: Which attack injects malicious scripts into web pages viewed by other users?
- Path Traversal
- Command Injection
- SQL Injection
- Cross-Site Scripting (XSS) (Correct answer)
Correct answer: Cross-Site Scripting (XSS)
Cross-Site Scripting (XSS) injects malicious client-side scripts into web pages, which then execute in the browsers of unsuspecting users.
Question 5: What does 'elasticity' mean in cloud computing?
- The durability guarantee for stored objects
- Automatic scaling of resources up or down to match demand (Correct answer)
- The ability to store elastic data formats like JSON
- Multi-region replication of services
Correct answer: Automatic scaling of resources up or down to match demand
Elasticity refers to the cloud's ability to automatically provision and release resources in near-real-time based on workload demand.
Question 6: What is the main purpose of database normalization?
- To increase query execution speed by adding redundant data
- To partition large tables across multiple servers
- To compress table data to reduce storage usage
- To reduce data redundancy and improve data integrity (Correct answer)
Correct answer: To reduce data redundancy and improve data integrity
Normalization organizes tables to minimize data redundancy, eliminate anomalies, and ensure data is stored logically and consistently.
Question 7: What is the difference between a process and a thread?
- A process has its own memory space; threads within a process share the same memory space (Correct answer)
- Processes are always faster than threads
- Threads have their own memory space; processes share memory
- Threads can only run on a single CPU core
Correct answer: A process has its own memory space; threads within a process share the same memory space
A process has an independent address space, while threads within the same process share the same address space but have separate stacks and registers.
Question 8: In Test-Driven Development (TDD), what is the correct order of steps?
- Refactor, write test, write code
- Write code, write test, refactor
- Write test, write code, refactor (Correct answer)
- Write test, refactor, write code
Correct answer: Write test, write code, refactor
TDD follows the Red-Green-Refactor cycle: write a failing test first, write code to pass it, then refactor.
Question 9: Which IAM concept groups multiple permissions together so they can be assigned to users or services as a unit?
- Permission boundary
- Group
- Policy (Correct answer)
- Role
Correct answer: Policy
An IAM policy is a document that defines a set of permissions and can be attached to users, groups, or roles.
Question 10: What type of attack exploits trust relationships between networked systems by forging the source IP address of packets?
- SQL injection
- IP spoofing (Correct answer)
- Buffer overflow
- Phishing
Correct answer: IP spoofing
IP spoofing forges the source IP address in packet headers to impersonate trusted hosts or conceal the attacker's origin.
Question 11: What is a 'breakpoint' in the context of debugging?
- A syntax error in the code
- A marker that pauses execution so the developer can inspect state (Correct answer)
- A test that intentionally fails
- A line where the program crashes
Correct answer: A marker that pauses execution so the developer can inspect state
A breakpoint is a deliberate stopping point set by the developer in a debugger to pause program execution and examine variables and flow.
Question 12: Which optimization technique moves a loop-invariant computation outside of the loop?
- Memoization
- Dead code elimination
- Loop unrolling
- Loop hoisting (code motion) (Correct answer)
Correct answer: Loop hoisting (code motion)
Loop hoisting (also called loop-invariant code motion) moves calculations whose result does not change across iterations outside the loop to avoid redundant work.
Question 13: Which searching algorithm requires the data to be sorted before it can be applied?
- Hash search
- Sequential search
- Binary search (Correct answer)
- Linear search
Correct answer: Binary search
Binary search works by repeatedly halving the search space, which only works correctly on a sorted dataset.
Question 14: What is a dashboard in CPA reporting?
- An IT-only tool
- A written monthly report
- A visual display of key metrics for at-a-glance performance monitoring (Correct answer)
- A physical control panel
Correct answer: A visual display of key metrics for at-a-glance performance monitoring
A dashboard consolidates important metrics and trends visually for quick assessment of performance status.
Question 15: Which data structure typically provides O(1) average-case lookup and is commonly used for caching optimizations?
- Binary search tree
- Hash table (Correct answer)
- Stack
- Linked list
Correct answer: Hash table
Hash tables map keys to values using a hash function, providing O(1) average-case lookup and making them ideal for caching and memoization.
Question 16: Which sorting algorithm has the best average-case performance of O(n log n) and is commonly used in standard library implementations?
- Quick sort (Correct answer)
- Bubble sort
- Selection sort
- Insertion sort
Correct answer: Quick sort
Quick sort achieves O(n log n) average-case and is favored in practice due to cache efficiency and low constant factors.
Question 17: Which pattern involves storing a copy of data in a faster storage medium to reduce repeated expensive computations or retrievals?
- Normalization
- Replication
- Sharding
- Caching (Correct answer)
Correct answer: Caching
Caching stores frequently accessed data in a fast storage layer (e.g., memory) so future requests for that data are served faster without hitting the primary source.
Question 18: Which HTTP method is used to partially update an existing resource?
- GET
- PATCH (Correct answer)
- POST
- PUT
Correct answer: PATCH
PATCH is used to apply partial modifications to a resource, unlike PUT which replaces the entire resource.
Question 19: What is the purpose of version control in software development?
- To store database backups
- To manage the software deployment
- To manage changes to code and support collaboration (Correct answer)
- To automate testing
Correct answer: To manage changes to code and support collaboration
Version control systems allow developers to track changes to code and collaborate with others effectively.
Question 20: What keyword is commonly used to exit a loop prematurely in most programming languages?
- exit
- continue
- break (Correct answer)
- return
Correct answer: break
The 'break' statement immediately terminates the innermost loop and transfers control to the statement after it.
Question 21: In Kubernetes, what resource acts as a stable network endpoint that load-balances traffic to a dynamic set of pods?
- Deployment
- Service (Correct answer)
- PersistentVolumeClaim
- Ingress
Correct answer: Service
A Kubernetes Service provides a stable virtual IP and DNS name that proxies traffic to matching pods, abstracting away individual pod IPs.
Question 22: What is the primary benefit of 'continuous integration' (CI) for testing?
- It tracks code coverage over time without running tests
- It deploys code directly to production after each commit
- It automatically runs tests on every code commit to catch failures early (Correct answer)
- It replaces the need for unit tests
Correct answer: It automatically runs tests on every code commit to catch failures early
CI systems trigger automated test suites on every commit, ensuring that integration or regression bugs are discovered quickly rather than accumulating.
Question 23: Which risk is most associated with the 'Big Bang' integration testing approach?
- Tests take too long to execute individually
- It requires expensive hardware to run
- It can only be performed after user acceptance testing
- All components are integrated at once, making it difficult to isolate the source of defects (Correct answer)
Correct answer: All components are integrated at once, making it difficult to isolate the source of defects
Big Bang integration combines all modules at once, so when failures occur it is extremely difficult to pinpoint which component or interface caused the problem.
Question 24: What is the index of the first element in a zero-indexed array with 8 elements?
- 8
- 1
- -1
- 0 (Correct answer)
Correct answer: 0
In zero-indexed arrays, the first element is always at index 0.
Question 25: What is the purpose of debugging in programming?
- To test code
- To improve performance
- To deploy the code
- To identify and fix errors in the code (Correct answer)
Correct answer: To identify and fix errors in the code
The purpose of debugging in programming is to systematically identify, analyze, and fix errors or 'bugs' within a computer program. When code doesn't behave as intended, developers use debugging tools and techniques to trace execution, inspect variables, and pinpoint the exact cause of the problem. This process ensures the software functions correctly and reliably.
Question 26: Which architectural style is best described as a pipeline where each component transforms data and passes it to the next?
- Pipe-and-filter architecture (Correct answer)
- Monolithic architecture
- Event-driven architecture
- Service-oriented architecture
Correct answer: Pipe-and-filter architecture
Pipe-and-filter architecture processes data through a sequence of independent filter components connected by pipes, common in data transformation systems.
Question 27: An algorithm that divides a problem into smaller subproblems of the same type and solves them recursively is using which strategy?
- Brute force
- Divide and conquer (Correct answer)
- Dynamic programming
- Greedy algorithm
Correct answer: Divide and conquer
Divide and conquer breaks a problem into smaller instances of itself, solves each recursively, and combines the results.
Question 28: Which of the following is a necessary condition for deadlock to occur?
- CPU burst time equality
- Preemption
- Mutual exclusion (Correct answer)
- Round-robin scheduling
Correct answer: Mutual exclusion
Mutual exclusion ā where at least one resource must be held non-shareably ā is one of the four necessary Coffman conditions for deadlock.
Question 29: Which design pattern allows incompatible interfaces to work together?
- Bridge
- Adapter (Correct answer)
- Composite
- Flyweight
Correct answer: Adapter
The Adapter pattern acts as a wrapper that converts the interface of a class into another interface that clients expect, enabling incompatible interfaces to collaborate.
Question 30: Which data structure is most appropriate for implementing a browser's back-navigation history?
- Binary search tree
- Stack (Correct answer)
- Hash table
- Queue
Correct answer: Stack
A stack's LIFO property naturally models back navigation ā the last page visited is the first retrieved.
Question 31: A function calls itself recursively without a base case. What type of error results?
- Off-by-one error
- Syntax error
- Stack overflow (infinite recursion) (Correct answer)
- Null pointer exception
Correct answer: Stack overflow (infinite recursion)
Without a base case, each recursive call adds a frame to the call stack until the stack's memory limit is exceeded, causing a stack overflow.
Question 32: Which isolation level prevents dirty reads but still allows non-repeatable reads?
- Serializable
- Read Committed (Correct answer)
- Repeatable Read
- Read Uncommitted
Correct answer: Read Committed
Read Committed prevents dirty reads by only seeing committed data, but another transaction can modify the row between two reads in the same transaction.
Question 33: In Unix-like systems, what is the init process (PID 1)?
- The ancestor of all processes, responsible for system initialization and orphan adoption (Correct answer)
- The kernel scheduler thread
- The memory manager daemon
- The first user application launched at login
Correct answer: The ancestor of all processes, responsible for system initialization and orphan adoption
The init process (PID 1) is the first user-space process started by the kernel; it initializes the system and becomes the parent of orphaned processes.
Question 34: Which Agile role is responsible for maximizing the value of the product and managing the product backlog?
- Development Team
- Project Sponsor
- Scrum Master
- Product Owner (Correct answer)
Correct answer: Product Owner
The Product Owner owns the product backlog, prioritizes items, and ensures the team is always working on the highest-value features.
Question 35: What is the space complexity of merge sort?
- O(n) (Correct answer)
- O(log n)
- O(1)
- O(n²)
Correct answer: O(n)
Merge sort requires O(n) auxiliary space for the temporary arrays used during merging.
Question 36: What is the time complexity of accessing an element in an array by its index?
- O(n)
- O(1) (Correct answer)
- O(n²)
- O(log n)
Correct answer: O(1)
Array index access is O(1) ā constant time ā because the memory address is calculated directly from the index.
Question 37: What is the primary purpose of refactoring code?
- Fixing bugs in production
- Improving code structure without changing external behavior (Correct answer)
- Adding new features to existing code
- Optimizing database queries
Correct answer: Improving code structure without changing external behavior
Refactoring improves the internal structure of code while preserving its observable behavior.
Question 38: What is object-oriented programming?
- A programming approach based on objects (Correct answer)
- A way to write assembly language
- A programming language
- A type of database management
Correct answer: A programming approach based on objects
Object-oriented programming (OOP) is a programming paradigm based on the concept of objects that contain both data and methods.
Question 39: In risk assessment, what does 'likelihood' refer to?
- The number of systems affected by a breach
- The probability that a threat will successfully exploit a vulnerability (Correct answer)
- The speed at which an attack can spread
- The financial cost of a security incident
Correct answer: The probability that a threat will successfully exploit a vulnerability
Likelihood in risk assessment measures how probable it is that a given threat will actually exploit a vulnerability and cause harm.
Question 40: Which SOLID principle states that a class should have only one reason to change?
- Single Responsibility Principle (Correct answer)
- Liskov Substitution Principle
- Open/Closed Principle
- Interface Segregation Principle
Correct answer: Single Responsibility Principle
The Single Responsibility Principle (SRP) states that a class should have only one responsibility and therefore only one reason to change.
Certified Associate Programmer (CPA) Exam
The Certified Associate Programmer (CPA) certification validates foundational knowledge in programming concepts, data structures, and algorithms, typically focusing on a specific language like Python or C++.
Exam Rules
- You can skip questions and return to them later
- Flag questions for review before submitting
- No feedback shown until you submit the entire exam
- Unanswered questions count as wrong ā answer everything
- 10 pretest questions are mixed in and don't affect your score
- Timer auto-submits when time runs out
- Your progress is auto-saved every 30 seconds