Interactive Web Pages :Programming Foundations with JavaScript, HTML and CSS (Java Programming and Software Engineering Fundamentals Specialization) Answers 2025
1. Question 1
Correct answer:
✔️ The code can check if the image is null before processing it.
❌ The code clears the canvas before performing the green screen algorithm.
❌ Global variables must be initialized when they are declared.
2. Question 2
Correct answers:
✔️ fgImage == null
✔️ ! fgImage.complete()
❌ fgImage.complete()
❌ fgImage != null
3. Question 3
Correct answer:
✔️ The first code block
Because the global x remains null and is checked after calling the function.
❌ The second block (checks inside function, but local variable shadows global).
❌ The third block (function changes global x to 2).
4. Question 4
Correct answer:
✔️ multiple=”false” (removes multi-file selection; default is single file)
❌ accept=”image/*” (only restricts file type)
❌ id=”finput” (only gives an ID)
5. Question 5
Correct answer:
✔️ A script specifying where to find the JavaScript library for SimpleImage
(SimpleImage must be imported or code won’t run.)
❌ var img = file.value (not required; SimpleImage needs the input element, not the value)
❌ var context = canvas.getContext(“2d”) (SimpleImage handles drawing internally)
6. Question 6
Correct answer:
✔️ Second pixel
Because rgb(153,51,255) has a much higher brightness average than rgb(0,153,153).
7. Question 7
Correct answer:
✔️ You would like to be able to reference the input element programmatically.
❌ An ID is required in order to use an event handler.
❌ The id attribute is required for input elements.
📌 Summary Table
| Q | Correct Answer(s) |
|---|---|
| 1 | The code can check if the image is null before processing it. |
| 2 | fgImage == null, !fgImage.complete() |
| 3 | First code block |
| 4 | multiple=”false” |
| 5 | Script for SimpleImage library |
| 6 | Second pixel |
| 7 | Reference the input element programmatically |