WGU D278 Final Exam Prep (Latest Update 2024 /
2025) Scripting and Programming - Foundations |
Questions and Verified Answers | 100% Correct |
Grade A
Section 1: Advanced Programming Concepts
Question 1
What is the primary purpose of a design pattern in software engineering?
A. To provide a reusable solution to a common problem
B. To enforce strict coding standards
C. To replace the need for documentation
D. To guarantee bug-free code
Correct Answer: A. To provide a reusable solution to a common problem
Rationale: Design patterns are reusable solutions to commonly
occurring problems in software design. They are not strict
standards (B), do not replace documentation (C), and cannot
guarantee bug-free code (D).
Question 2
Which design pattern ensures a class has only one instance and provides
a global point of access to it?
A. Factory
B. Singleton
,C. Observer
D. Decorator
Correct Answer: B. Singleton
Rationale: The Singleton pattern restricts instantiation of a class to
one object. Factory (A) creates objects. Observer (C) handles event
notification. Decorator (D) adds responsibilities dynamically.
Question 3
Which design pattern defines a family of algorithms, encapsulates each
one, and makes them interchangeable?
A. Strategy
B. Adapter
C. Facade
D. Proxy
Correct Answer: A. Strategy
Rationale: The Strategy pattern allows algorithms to vary
independently from clients. Adapter (B) converts interfaces. Facade
(C) simplifies a subsystem. Proxy (D) controls access.
Question 4
What is the purpose of the Model-View-Controller (MVC) architectural
pattern?
A. To separate data, presentation, and logic
B. To combine data and presentation
C. To eliminate the need for a database
D. To speed up compilation
,Correct Answer: A. To separate data, presentation, and logic
Rationale: MVC separates internal representations of information
from the ways information is presented to and accepted from the
user.
Question 5
What is a race condition in concurrent programming?
A. A behavior where the output depends on the sequence or timing of
uncontrollable events
B. A condition where two threads execute in perfect sequence
C. A condition where a program runs faster than expected
D. A condition where memory is automatically freed
Correct Answer: A. A behavior where the output depends on the sequence
or timing of uncontrollable events
Rationale: Race conditions occur when multiple threads access
shared data simultaneously, and the outcome depends on timing.
Question 6
What is a deadlock?
A. A situation where two or more threads are blocked forever, waiting for
each other
B. A situation where a thread finishes execution
C. A situation where a program crashes
D. A situation where memory is leaked
Correct Answer: A. A situation where two or more threads are blocked
forever, waiting for each other
, Rationale: Deadlock occurs when processes hold resources and wait
for resources held by others.
Question 7
What is a mutex?
A. A synchronization primitive used to protect shared resources
B. A type of loop
C. A data structure for storing strings
D. A function for sorting
Correct Answer: A. A synchronization primitive used to protect shared
resources
Rationale: A mutex (mutual exclusion) ensures that only one thread
accesses a resource at a time.
Question 8
What is a semaphore?
A. A synchronization primitive that controls access to a common resource
by multiple processes
B. A type of variable
C. A sorting algorithm
D. A data structure
Correct Answer: A. A synchronization primitive that controls access to a
common resource by multiple processes
Rationale: Semaphores use counters to manage access to shared
resources.
2025) Scripting and Programming - Foundations |
Questions and Verified Answers | 100% Correct |
Grade A
Section 1: Advanced Programming Concepts
Question 1
What is the primary purpose of a design pattern in software engineering?
A. To provide a reusable solution to a common problem
B. To enforce strict coding standards
C. To replace the need for documentation
D. To guarantee bug-free code
Correct Answer: A. To provide a reusable solution to a common problem
Rationale: Design patterns are reusable solutions to commonly
occurring problems in software design. They are not strict
standards (B), do not replace documentation (C), and cannot
guarantee bug-free code (D).
Question 2
Which design pattern ensures a class has only one instance and provides
a global point of access to it?
A. Factory
B. Singleton
,C. Observer
D. Decorator
Correct Answer: B. Singleton
Rationale: The Singleton pattern restricts instantiation of a class to
one object. Factory (A) creates objects. Observer (C) handles event
notification. Decorator (D) adds responsibilities dynamically.
Question 3
Which design pattern defines a family of algorithms, encapsulates each
one, and makes them interchangeable?
A. Strategy
B. Adapter
C. Facade
D. Proxy
Correct Answer: A. Strategy
Rationale: The Strategy pattern allows algorithms to vary
independently from clients. Adapter (B) converts interfaces. Facade
(C) simplifies a subsystem. Proxy (D) controls access.
Question 4
What is the purpose of the Model-View-Controller (MVC) architectural
pattern?
A. To separate data, presentation, and logic
B. To combine data and presentation
C. To eliminate the need for a database
D. To speed up compilation
,Correct Answer: A. To separate data, presentation, and logic
Rationale: MVC separates internal representations of information
from the ways information is presented to and accepted from the
user.
Question 5
What is a race condition in concurrent programming?
A. A behavior where the output depends on the sequence or timing of
uncontrollable events
B. A condition where two threads execute in perfect sequence
C. A condition where a program runs faster than expected
D. A condition where memory is automatically freed
Correct Answer: A. A behavior where the output depends on the sequence
or timing of uncontrollable events
Rationale: Race conditions occur when multiple threads access
shared data simultaneously, and the outcome depends on timing.
Question 6
What is a deadlock?
A. A situation where two or more threads are blocked forever, waiting for
each other
B. A situation where a thread finishes execution
C. A situation where a program crashes
D. A situation where memory is leaked
Correct Answer: A. A situation where two or more threads are blocked
forever, waiting for each other
, Rationale: Deadlock occurs when processes hold resources and wait
for resources held by others.
Question 7
What is a mutex?
A. A synchronization primitive used to protect shared resources
B. A type of loop
C. A data structure for storing strings
D. A function for sorting
Correct Answer: A. A synchronization primitive used to protect shared
resources
Rationale: A mutex (mutual exclusion) ensures that only one thread
accesses a resource at a time.
Question 8
What is a semaphore?
A. A synchronization primitive that controls access to a common resource
by multiple processes
B. A type of variable
C. A sorting algorithm
D. A data structure
Correct Answer: A. A synchronization primitive that controls access to a
common resource by multiple processes
Rationale: Semaphores use counters to manage access to shared
resources.