Skip to content

Overview of Programming Concepts :Programming Foundations with JavaScript, HTML and CSS (Java Programming and Software Engineering Fundamentals Specialization) Answers 2025

1. Question 1

Correct Answer:
✔️ Option 1 — if (x > y) then set red & blue = 0

Because: the diagonal where x > y is the region below the diagonal, typically where green appears.


2. Question 2

To turn the yellow image into green, we must remove red (set it to 0).

Correct Answer:
✔️ pixel.setRed(0);


3. Question 3

We need functions that correctly detect borders using thickness and use setBlack(px).

Correct Implementations:
✔️ Option 1
✔️ Option 4


4. Question 4

Purpose: Identify whether a pixel lies within any edge border.

Correct Answer:
✔️ To identify pixels that are within the borders by returning true


5. Question 5

Since the function colors all border pixels black, the only outputs that cannot be produced are those missing a border or incorrectly bordered.

Correct Answers:
✔️ Any image that does not have complete black borders on all four sides
(Since I cannot see your images, I mark the rule: choose all images without full border.)


6. Question 6

Correct composition is:

Correct Answer:
✔️ return word + separator + word + separator + word;


7. Question 7

Given: x = 30, y = 8

  • x > 10 → true → prints "one"

  • y < 10 → true → prints "two"

  • x < 20 → false → second block skipped → prints nothing

Correct Answer:
✔️ one
two


8. Question 8

moreRedThanGreen must:

  1. Load image

  2. Loop through pixels

  3. Count those with red > green

  4. Return count

Correct Missing Code (expected logic):
✔️

var count = 0;
for (var pixel of image.values()) {
if (pixel.getRed() > pixel.getGreen()) {
count = count + 1;
}
}
return count;

9. Question 9

numberRedPixels(namefile, low, high) should:

Count pixels whose red is between low and high (inclusive).

Correct Missing Code:
✔️

var count = 0;
for (var pixel of image.values()) {
var r = pixel.getRed();
if (r >= low && r <= high) {
count++;
}
}
return count;

10. Question 10

Best parameters:

✔️ filename, low, high

Because we only need:

  • image file

  • low threshold

  • high threshold

Correct Answer:
✔️ Three parameters: filename, low, high


📘 Summary Table

Q Correct Answer ✔️
1 if (x > y) set red/blue to 0 ✔️
2 pixel.setRed(0) ✔️
3 Options 1 & 4 ✔️
4 Identify pixels within borders ✔️
5 Any image without full black border ✔️
6 return word + sep + word + sep + word ✔️
7 one, two ✔️
8 Count red>green ✔️
9 Count red between low & high ✔️
10 filename, low, high ✔️