Module 5: Final project

Course quiz: Application development

Graded Assignment

1. True or False: The following code snippet meets the requirement for mobile compatibility?

// Requirements provided:
// 1. Login form must work on mobile devices
// 2. Log errors on incorrect login


// Missing Requirement?
public boolean isValid(String username, String password) {
if(username == null || password == null){
return false;
}
return true;
}

  • True
  • False ✅

Explanation:
The code snippet checks for null values in the username and password, but it doesn’t meet the stated requirements:

  1. The login form must work on mobile devices: The code snippet doesn’t show any handling for mobile responsiveness.
  2. Log errors on incorrect login: There is no logging implemented in the snippet.

2. A developer fixes an error message in one sprint but adds an authentication feature in the next sprint. What does each change represent?

  • Fixing is an increment; adding is an iteration.
  • Both are increments.
  • Fixing is an iteration; adding is an increment.
  • Both are iterations.

3. Which of the following is an example of a functional requirement?

  • The system should be accessible in all locales.
  • The system should respond within 2 seconds.
  • The code should follow clean code principles.
  • The system should allow users to reset their password. ✅

Explanation:
Functional requirements describe specific behaviors or functions of a system. Password reset functionality is a concrete feature that the system must provide.

4. True or False: A software program must handle 10,000 users simultaneously and provide a response within 2 seconds. This is an example of a functional requirement.

  • True
  • False ✅

Explanation:
Handling 10,000 users simultaneously and providing responses within 2 seconds is a performance requirement, which is non-functional.

5. You are reviewing the implementation of a "Save" feature based on the user story and acceptance criteria below.

User story: Add a save button

Acceptance criteria:

The button must save data.

The button must provide feedback on saving (success/failure).

True or False: Based on the initial implementation provided, the saveData method fully meets the acceptance criteria.

public void saveData() {
// Code to save data
}

  • True
  • False ✅

Explanation:
The provided saveData method lacks feedback (success/failure), which violates the acceptance criteria.

6. Which INVEST attribute ensures a requirement that can be verified through criteria?

  • Independent
  • Negotiable
  • Small
  • Testable ✅

Explanation:
The INVEST model requires requirements to be testable, ensuring they can be verified against defined criteria.

7. A team uses the Singleton pattern to manage a shared configuration object. What benefits does this pattern provide? Select all that apply.

  • It makes the code completely thread-safe.
  • It provides controlled access to a single instance. ✅
  • It ensures only one instance exists globally. ✅
  • It facilitates lazy initialization to improve performance. ✅

Explanation:
The Singleton pattern ensures global access, single-instance management, and supports lazy initialization. Thread-safety requires additional implementation.

8. What type of relationship is depicted in this UML diagram?

  • Global access method
  • A one-to-many relationship ✅
  • Instantiation
  • Private constructor

Explanation:
The diagram indicates one author can write multiple books, which is a one-to-many relationship.

9. How does an epic differ from a user story? Select all that apply.

  • An epic focuses on broader objectives, while a user story focuses on specific user needs. ✅
  • An epic spans multiple iterations, while a user story is typically completed within one iteration. ✅
  • An epic represents a larger requirement split into multiple user stories. ✅
  • An epic does not require acceptance criteria, unlike a user story which does.

10. What pattern is being implemented in this code?

public class Logger {
private static Logger instance;


private Logger() {}


public static Logger getInstance() {
if (instance == null) {
instance = new Logger();
}
return instance;
}
}

  • Factory
  • Observer
  • Builder
  • Singleton ✅

Explanation:
The code ensures only one instance of Logger is created, which is the hallmark of the Singleton pattern.

11. In the ToDoRails Elite Application, what is the primary purpose of implementing the SecurityConfig class?

  • To handle task creation
  • To format log messages
  • To manage database connections
  • To configure authentication and secure API endpoints ✅

Explanation:
The SecurityConfig class is primarily responsible for authentication and securing endpoints in a Spring Boot application.

12. Which of the following are core components of UML notation? Select all that apply.

  • Markup Tags
  • Use Cases ✅
  • Actors ✅
  • Scripts

Explanation:
Use cases and actors are core components of UML notation. Markup tags and scripts are not part of UML.

13. Which of the following is a phase of Agile methodology?

  • Development Cycle
  • Sprint Retrospective ✅
  • Test Completion Phase
  • Planning Phase

Explanation:
The Sprint Retrospective is a key phase in Agile methodology for reflecting on the sprint and identifying improvements.

14. Which principle of clean code ensures that methods have a specific purpose?

  • Fail Fast
  • Single Responsibility Principle ✅
  • DRY
  • Short Functions

Explanation:
This principle ensures each method has one specific purpose, promoting clarity and maintainability.

15. What is the main purpose of the class SimpleGrantedAuthority in Spring Security?

  • To allow only simple unencrypted username and password usage in Spring Security
  • To define roles or authorities granted to a user.
  • To enable the management of all combination of username and password in Spring Security
  • To enable auto configuration of spring security.

Explanation:
SimpleGrantedAuthority is used to define user roles and authorities in Spring Security.

16. A software development team has been hired to build a mobile app for a fitness startup. The client wants to review and provide feedback on each feature as it’s developed, ensuring the app aligns with their vision and adapts to new requirements based on market trends. The project will involve frequent iterations and updates. Which SDLC model is most appropriate for this project?

  • V-Model
  • Agile ✅
  • Waterfall
  • Spiral

Explanation:
The Agile model supports frequent iterations and user feedback, which aligns with the project’s requirements.

17. A team plans its workflow on a board showing task stages but doesn’t define fixed iterations. Which Agile framework are they likely using?

  • Dynamic Systems Development Method (DSDM)
  • Extreme Programming (XP)
  • Kanban ✅
  • Scrum

Explnation:
Kanban focuses on workflow visualization and continuous delivery without fixed iterations.

18. A developer wants to pause execution only when a variable x exceeds 100. Which debugging tool should they use?

  • Variable Watch
  • Regular breakpoint
  • Conditional breakpoint ✅
  • Step Over

Explanation:
A conditional breakpoint pauses execution only when specific conditions (e.g., x > 100) are met.

19. Where should you place the @EnableWebSecurity(debug=true) annotation in your Spring Boot application?

  • On the class which acts as a service to the User class (the class representing the user in the Spring Boot application)
  • On the controllers that handle requests for endpoints to secure all endpoints
  • On a class which is annotated with @Configuration where the SecurityFilterChain bean is defined ✅
  • On the class that represents the user, such as the User class, which contains the roles

Explanation:
The @EnableWebSecurity annotation is typically placed on a configuration class.

20. What is the primary purpose of using logging in an application?

  • To replace exception handling
  • To replace debugging entirely
  • To monitor and troubleshoot application behavior ✅
  • To generate user documentation

Explanation:
Logging helps in understanding the application’s runtime behavior and identifying issues.

21. What is the purpose of the git commit command in the following code block?

git add .
git commit -m "Initial commit"
git push origin main

  • To clone the repository to your system
  • To stage all files for tracking
  • To upload changes to the remote repository
  • To save changes locally with a message ✅

Explanation:
The git commit command saves changes locally with the provided message.

22. A developer wants to collaborate on a public GitHub repository. What should they do first?

  • Clone the repository
  • Fork the repository ✅
  • Delete the repository locally
  • Push changes directly to the main branch

Explanation:
Forking creates a personal copy of the repository to work on and contribute to.

23. How can this code better adhere to the Don’t Repeat Yourself (DRY) principle?

public int calculateSum(int[] numbers) {
int sum = 0;
for (int i = 0; i < numbers.length; i++) {
sum += numbers[i];
}
return sum;
}
public int calculateAverage(int[] numbers) {
int sum = 0;
for (int i = 0; i < numbers.length; i++) {
sum += numbers[i];
}
return sum/ numbers.length;
}

  • Combine both methods into one
  • Call the calculateSum method inside the calculateAveragemethod ✅
  • Replace the loop with an if-else statement
  • Add additional functionality to calculate other statistics

Explanation:
Reusing the calculateSum method eliminates repetition, adhering to the DRY principle.

24. What is the purpose of @ControllerAdvice in a Spring Boot application?

  • To globally handle exceptions and provide error responses for controllers ✅
  • To remind the developer of advice from the team head during development
  • To display advice to the browser when the user sends the wrong request
  • To set the best security configurations for controllers

Explanation:
@ControllerAdvice is used for centralized exception handling across multiple controllers.

25. When is it most appropriate to use wireframes during UI design?

  • During the final visual design phase
  • During deployment
  • During the initial layout planning phase ✅
  • After UI testing is complete

Explanation:
Wireframes are used early in design to plan layouts and structures.

26. A team automates testing after every code commit to ensure immediate feedback. Which DevOps practice does this represent?

  • Monitoring
  • Logging
  • Continuous Integration ✅
  • Continuous Deployment

Explanation:
Automated testing after every code commit is a key aspect of Continuous Integration.

27. The cost of software maintenance increases significantly when ____ is not prioritized during development.

  • Logging
  • Maintainability
  • Deployment
  • Scalability

Explanation:
Prioritizing maintainability reduces the cost of software maintenance.

28. What is the purpose of Spring Profiles in deployment?

  • To automate software testing
  • To deploy microservices
  • To debug applications
  • To manage environment-specific configurations ✅

Explanation:
Spring Profiles simplify the management of configurations for different environments (e.g., dev, test, prod).

29. What is one common challenge when investigating software issues?

  • Overuse of system resources
  • Clear logging messages
  • Differences between environments ✅
  • Simplified debugging tools

Explanation:
Issues often arise from inconsistencies between development, testing, and production environments.

30. What does the @Mock annotation achieve in this test?

@Mock
private UserService userService;

@InjectMocks
private UserController userController;

@Test
public void testGetUser() {
when(userService.getUserById(1)).thenReturn(new User("John"));
assertEquals("John", userController.getUser(1).getName());
}

  • It injects dependencies into the controller
  • It isolates the database layer
  • It validates the response from the controller
  • It replaces the actual service with a simulated version ✅

Explanation:
@Mock creates a mock object, allowing testing without relying on the actual service.

 

Leave a Reply