F Exam

Last updated: 2024-07-21 15:48:13

F.1 General information

Some technical details about the exam:

  • The exam takes place in Semester A, and is 40% of the grade
  • The exam will consist of 8 multiple-choice questions
  • Exam duration is 2 hours
  • The exam takes place in a regular class, with pen and paper (not in front of a computer)

F.2 Topics

The material for the exam includes:

  • Chapters 14

F.3 Sample questions

Question 1

Which HTML element is used to create a top-level (largest) heading?

  1. <h1>

  2. <h6>

  3. <heading>

  4. <head>

Question 2

Given the following HTML code for a list with three items:

<ul>
  <li class="hot" id="first">Coffee</li>
  <li class="hot">Tea</li>
  <li class="cold">Milk</li>
</ul>

which CSS code, when linked to the HTML document, will result in the first and third item displayed with the same color?

  1. .hot {color: black} .cold {color: blue}

  2. #first {color: red}

  3. #cold {color: blue}

  4. .cold {color: blue}

Question 3

What will be the value of arr after running the following expressions?

let obj = {type: "Point", coordinates: [20, 30]};
let arr = obj.coordinates;
arr.push(arr[1]);
  1. [20, 30, 1]

  2. 3

  3. [20, 30]

  4. [20, 30, 30]

Question 4

What will be the value of y after running the following expressions?

let x = [{value: 3}, {value: 4}, {value: 5}];
let y = [];
x.forEach(function(element) { y.push(element.value); });
  1. undefined

  2. []

  3. [{value: 3}, {value: 4}, {value: 5}]

  4. [3, 4, 5]

Question 5

What will appear in the main browser window when loading an HTML document with the following contents?

<!DOCTYPE html>
<html>
<head></head>
<body>
  <p id="intro">Hello
  world
  </p>
</body>
</html>
  1. The words “Hello” and “world”, on two separate lines

  2. The phrase “Hello world”, on one line

  3. Blank page

  4. The phrase “intro Hello world”, on one line

Question 6

What is the right expression to clear the contents of a paragraph that has id="main"?

  1. document.getElementById("main")[0].innerHTML = "";

  2. document.getElementById("#main").innerHTML = "";

  3. document.getElementById("main").innerHTML = "";

  4. document.getElementById("main").innerHTML = 0;

Question 7

What will be the value of y after running the following expressions?

let x = {value: [41, 42, 43, 44]};
let y = x.value[x.value.length - 2];
  1. 41

  2. 42

  3. 43

  4. 44

Question 8

Which text will appear in the main browser window when loading an HTML document with the following contents, and clicking on the button twice?

<!DOCTYPE html>
<html>
<head></head>
<body>
  <p id="intro">Hi All</p>
  <input type="button" id="button" value="Click me!">
  <script>
    document
        .getElementById("button")
        .addEventListener("click", function() {
            let el = document.getElementById("intro");
            let html = el.innerHTML;
            el.innerHTML += html;
        })
  </script>
</body>
</html>
  1. Hi All

  2. Hi AllHi All

  3. Hi All Hi All Hi All Hi All

  4. Hi AllHi AllHi AllHi All