Module 4: Final project and course wrap up
Looking for ‘full stack web development module 4 answers‘?
In this post, I provide accurate answers and detailed explanations for Module 4: Final project and course wrap up of Course 5: Full Stack Web Development – Amazon Junior Software Developer Professional Certificate.
Whether you’re preparing for quizzes or brushing up on your knowledge, these insights will help you master the concepts effectively. Let’s dive into the correct answers and detailed explanations for each question.
Course quiz: Full stack web development
Practice Assignment
1. You are creating a form for a feedback page. The form should send the user's input to a server endpoint at/submit-feedback. Which HTML attribute will you use to specify this URL, and how should it look?
- <form method=”POST” action=”/submit-feedback”> ✅
- <form url=”/submit-feedback” method=”POST”>
- <form destination=”/submit-feedback” method=”POST”>
- <form route=”/submit-feedback” method=”POST”>
Explanation:
The action
attribute specifies the URL the form data will be sent to. The method
attribute defines the HTTP method (e.g., POST, GET) to use when sending form data.
2. In an HTML document, which tags should you use to contain the main visible content of your web page?
- <head> and </head>
- <html> and </html>
- <title> and </title>
- <body> and </body> ✅
Explanation:
The <body>
tag contains all the visible elements of a web page, including headings, paragraphs, images, links, and other content.
3. You are creating a web page with a clickable hyperlinked image logo. Which of the following HTML snippets will you use?
Explanation:
The <a>
tag creates the hyperlink, and the <img>
tag is nested inside to make the image clickable. The href
attribute specifies the target URL, and the src
attribute in <img>
defines the image source.
4. You create a CSS rule to style multiple elements differently based on their IDs. Which CSS rules are valid for targeting elements by their IDs? Select all that apply.
Explanation:
In CSS, IDs are targeted with the #
symbol. Rules without #
will not apply to IDs.
5. True or false: You are designing a responsive image gallery. Using a media query with max-width ensures that specific styles are applied when the screen width is smaller than the specified value.
- True ✅
- False
Explanation:
The max-width
rule applies specific styles when the screen width is smaller than the specified value, enabling responsive design.
6. You are designing a simple calculator web page. You want to store the calculation result in an existing variable named result. Which JavaScript statement correctly assigns the sum of two numbers, 5 and 10, to the result variable as 15?
- result = 5 + “10”;
- result = sum(5, 10);
- result = 5 + 10; ✅
- var result = 5 + 10;
Explanation:
This correctly computes the sum of two numbers. Using a string ("10"
) or an undefined function (sum
) will lead to errors or incorrect results.
7. You are adding a validation step to your form. Complete the following JavaScript code to attach an onsubmit event listener to the form with id="bookForm" that prevents form submission and displays an alert message:
- click
- load
- submit ✅
- onsubmit
Explanation:
The event listener should listen for the submit
event to trigger the provided function when the form is submitted.
8. Which of the following annotations are commonly used to define a controller method in Spring MVC, for requests from a browser? Select all that apply
- @Service
- @PostMapping
- @RequestMapping ✅
- @GetMapping ✅
Explanation:
These annotations define how methods in a Spring controller map to specific HTTP requests.
9. The following code block is incomplete. To pass a list of products to the Thymeleaf view by adding an attribute named productList, choose the correct option to replace line 3.
- model.addAttribute(“productList”, productService.getAllProducts()) ✅
- model.addAttributeAsProductList(productService.getAllProducts())
- model.addAttribute(productService.getAllProducts())
- model.addAttribute(“productList”)
Explanation:
The addAttribute
method adds data to the model, which is accessible in the Thymeleaf view.
10. You are configuring your Spring Boot application and want to set up a custom server port. Complete the following line in the application.properties file to change the server port to 8081:
.port =8081
What is the missing--------?
- server ✅
- tomcat
- address
- host
Explanation:
The server.port
property in application.properties
configures the port for the Spring Boot application.
11. You are configuring Spring Security to allow access to static JavaScript files located in the /js folder without authentication. Complete the missing part of the following SecurityFilterChain configuration.
What should replace the--------?
- anyRequest
- allowAccess
- permitAll ✅
- authenticated
Explanation:
The permitAll
method allows unrestricted access to the specified resources.
12. You are building a Spring MVC application to manage products. The user submits a form to add a new product. Which annotations should you use in the controller method to handle this form submission and bind the form data to a Product object?
- @PostMappingand@RequestParam
- @GetMappingand@RequestParam
- @GetMapping and Model
- @PostMapping and @ModelAttribute ✅
Explanation:@PostMapping
maps the form submission, and @ModelAttribute
binds form data to an object.
13. What will result from the following request mapping in a Spring MVC controller when you are using Thymeleaf?
- Displays the home.html page in the browser. ✅
- Redirects to /home endpoint.
- Shows a blank page.
- Displays thehome.jsp page in the browser.
Explanation:
The returned string matches a Thymeleaf template (home.html
) in the templates
folder.
14. What is the purpose of @Autowired annotation in Spring Boot?
- To inject dependencies automatically ✅
- To configure database connections
- To wire up the system with Tomcat server
- To specify a default value for a variable
Explanation:@Autowired
is used for dependency injection in Spring Boot.
15. A user accesses your Spring Boot web app, but they see the following Whitelabel Error Page:
There was an unexpected error (type=Not Found, status=404).
No message available
What does this error indicate?
- The application cannot connect to the database.
- The application failed to start.
- The server is down.
- The requested URL does not exist. ✅
Explanation:
A 404 error means the server couldn’t find the requested resource.
16. If you are developing a secure Spring Boot application and want to restrict access to certain endpoints, which Spring Boot feature would you use to handle authentication and authorization?
- Spring DevTools
- Spring Data JPA
- Spring Security ✅
- Spring Web
Explanation:
Spring Security provides robust tools for handling authentication and authorization.
17. Which HTTP method would you use in Postman to retrieve data from a Spring Boot API?
- DELETE
- PUT
- GET ✅
- POST
Explanation:
The GET
method retrieves data without modifying the server’s state.
18. You are developing a RESTful API for a task management app. Which annotation should you use to map an HTTP GET request to a specific method?
- @GetMapping ✅
- @DeleteMapping
- @PutMapping
- @PostMapping
Explanation:
The @GetMapping
annotation maps HTTP GET requests to a controller method.
19. For updating a resource
What will replace --------?
- GetMapping
- DeleteMapping
- PostMapping
- PutMapping ✅
Explanation:@PutMapping
is used to update an existing resource.
20. Which of the following HTML elements is used to create a dropdown in a form?
- <input>
- <select> ✅
- <button>
- <textarea>
Explanation:
The <select>
tag creates a dropdown menu in a form.
21. You have the following JPA entity:
What will happen when a new product is saved in the database?
- An error will occur due to missing @Column annotations.
- The id must be provided manually.
- The id will be automatically generated. ✅
- The name field will be ignored.
Explanation:@GeneratedValue
automatically generates values for the primary key.
22. What is the primary purpose of building a Spring Boot application as a JAR file?
- To create a deployable web archive for a stand-alone web server
- To package the application with an embedded server for standalone deployment ✅
- To generate the documentation in a JAR package
- To generate compiled source code
Explanation:
Spring Boot JARs include an embedded server, making them runnable as standalone applications.
23. You have the following HTML form:
Which Spring MVC controller method will handle this form submission?
- @PutMapping(“/register”)
- @DeleteMapping(“/register”)
- @PostMapping(“/register”) ✅
- @GetMapping(“/register”)
Explanation:@PostMapping
handles HTTP POST requests, matching the form’s method attribute.
24. Which HTML tag is used to create an ordered list?
- <ul>
- <ol> ✅
- <dl>
- <li>
Explanation:
The <ol>
tag creates an ordered (numbered) list.
25. Which HTML element and attribute are used to hyperlink to another page?
- <a> with href ✅
- <a> with src B:
- <link> with src
- <link> with href
Explanation:
The <a>
tag and href
attribute define hyperlinks.
26. Which CSS property is used to define a flex container?
- justify-content
- align-items
- display: flex ✅
- flex-direction
Explanation:
The display: flex
property makes an element a flex container.
27. Fill in the blank to create a border with a width of 2px and a solid style:
What will replace the--------?
- 2pt solid
- 2px
- 2em solid
- 2px solid ✅
Explanation:
This specifies a 2-pixel-wide solid border.
28. You are testing the following code:
What will be the output in the console?
- 1, 2
- 0, 1, 2 ✅
- 1, 2, 3
- 0, 1, 2, 3
Explanation:
The loop runs while the condition is true, incrementing count
and printing it.
29. You are building a Spring Boot REST API to return a welcome message. Which of the following methods correctly returns a ResponseEntity with a message "Welcome!" and an HTTP 200 status?
- return ResponseEntity.notFound().build();
- return “Welcome!”;
- return ResponseEntity.ok(“Welcome!”); ✅
- return ResponseEntity.status(500).body(“Welcome!”);
Explanation:ResponseEntity.ok()
returns a 200 status with the specified body.
30. Fill in the blank to send a POST request using the Fetch API with a JSON payload:
What will be used to replace the --------?
- {name: “Alice” }
- JSON.stringify({ name: “Alice” }) ✅
- JSON.parse({ name: “Alice” })
- encodeURI({ name: “Alice” })
Explanation:JSON.stringify
converts the JavaScript object to a JSON string for the request body.
Related contents:
Module 1: Frontend development
Module 2: Java web development
Module 3: Web APIs
You might also like:
Course 1: Introduction to Software Development
Course 2: Programming with Java
Course 3: Data Structures and Algorithms
Course 4: Database Management with Java and SQL
Course 6: Generative AI in Software Development
Course 7: Application Development