Internet Programming and Applications - Exam

UNIVERSITY OF DODOMA

ACADEMIC YEAR 2023/2024


SECTION A

Question One: Multiple Choice

viii. Which of the following jQuery method is used to attach a handler to an event?
(1 Mark)

  • A. unbind () method
  • B. attach () method
  • C. bind () method
  • D. None of the above

ix. $(this) in jQuery is used when:
(1 Mark)

  • A. an HTML element references the entire document
  • B. an HTML element references its own action
  • C. an HTML element references the action of its parent element
  • D. All of the above

x. Which type of JavaScript language is:
(1 Mark)

  • A. Object-Oriented
  • B. Object-Based
  • C. Assembly-language
  • D. High-level

Question Two: Fill in the Blanks

a. ______ tag contain information about the author, copyright information, etc.
(1 Mark)

b. ______ tag can be used to mark up a conversation.
(1 Mark)

c. ______ represents a measurement, such as disk usage.
(1 Mark)

d. ______ improve the performance of our websites by avoiding the need to download images off the network.
(1 Mark)

e. ______ element represents a run of text in one document marked or highlighted for reference purposes.
(1 Mark)

f. ______ tag represents a section of the document intended for navigation.
(1 Mark)

g. ______ tag represents a piece of content that is only slightly related to the rest of the page.
(1 Mark)

h. ______ tag represents an independent piece of content of a document, such as a blog entry or newspaper.
(1 Mark)

i. ______ tag represents a generic document or application. It can be used together with h1-h6 to indicate the document structure.
(1 Mark)

j. ______ tag can be used to associate a caption together with some embedded content, such as a graphic or video.
(1 Mark)


Question Three: True or False

a. JavaScript is a compiled language
(1 Mark)

b. With an external style sheet, you can change the look of an entire website by changing just one file.
(1 Mark)

c. jQuery can be used to create AJAX applications.
(1 Mark)

d. Using the Javascript const keyword to declare a variable ensures that it will not be reassigned within its scope.
(1 Mark)

e. HTML is used to create the structure of a web page.
(1 Mark)

f. jQuery is a replacement for JavaScript.
(1 Mark)

g. Some browsers do not support images. In this case, the alt attribute can be used to create text that appears instead of the image.
(1 Mark)

h. When a Web browser displays a table, it often adds extra space. To eliminate this space use the width attribute in the <table> and <td> tags.
(1 Mark)

i. A font family is a set of fonts that have similar characteristics.
(1 Mark)

j. jQuery Method Chaining allows us to run multiple jQuery methods (on the same element) within a single statement.
(1 Mark)


Question Four: CSS Rules

i. Make all text in the body of the document double the normal size and color the text red.
(2 Marks)

ii. Place a background image halfway down the page, tiling it horizontally. The image should remain in place as the user scrolls up or down.
(2 Marks)

iii. All h1 and h2 elements in the web page should have the following styles applied: a padding of 0.5 ems, a dashed border style, and a margin of 0.5 ems.
(2 Marks)

iv. Change the color of all elements with the ā€œgreen-moveā€ class to green, and shift them down 25 pixels and to the right 15 pixels.
(2 Marks)

v. Write a layout template that contains a header and two columns. Use division tags for each layout component, and use float to line up the columns side by side. Give each component a border and or a background color so you can see in which division tag you are.
(2 Marks)


Question Five: Pregnant Mothers Web Application

Assume you are a front-end developer and you are tasked to create a web application that stores information about pregnant mothers. The application needed to capture the following details about each pregnant mother: first name, middle name, surname, email address, and phone number. During the development process, the client added a requirement to also capture information about the pregnancy. Specifically, the application needed to determine whether the pregnancy was a twin or not. If the pregnancy was not a twin, the application should capture the gender and weight of the child. If the pregnancy was a twin, the application should capture the number of children (ie, the number of twins could be 2, 3, etc.). For a twin pregnancy, the application should capture the weight and gender of each child. So the number of input fields for gender and weight would depend on the number of twins. For example, if the number of twins is two, then the application should have two input fields each for the gender and weight of the two children. You were asked to use HTML, CSS, and jQuery to create the form to capture all this information. You also needed to use JavaScript to validate the form, ensuring that no required field is left empty and that the data entered is valid. All fields should be mandatory except the middle name. (20 Marks)


Question Six: To-Do List Application

Imagine you are building a web application that allows users to create and manage their personal to-do lists. When a user click ā€œAddā€ button, a function named ā€œaddTodoltemā€ should be called to allow user to add a new to-do item by entering a task description in an input field. When the user adds a new to-do item, it should be displayed in a table with id=ā€œlist-itemsā€. Each to-do item in the list should have a checkbox to mark it as completed, and a ā€œDeleteā€ button. When the user clicks the checkbox for a to-do item, a function named ā€œcompleteTaskā€ should to called to visually indicated the task as completed (by adding a strikethrough to the text). When the user clicks the ā€œDeleteā€ button for a to-do item, the application should call a function ā€œdeleteltemā€ which confirm the deletion with the user before removing the item the from the list. Use DOM and BOM manipulations to implement the above functionalities. (20 Marks)


Mr. Siphael is selling his car online. He has taken several photos of the car’s exterior and interior, and he wants to display them on a webpage so potential buyers can view the car. He would like the webpage to have a large main image area that displays the selected photo, and a set of thumbnail images that the user can click to update the main image. Write the necessary code in a file called ā€˜car.js’ that uses jQuery to implement the following functionality: • When the user clicks on a thumbnail image of the car’s exterior, the large exterior shot should be displayed in the main image area (the image with the ID ā€˜car’). • When the user clicks on a thumbnail image of the car’s interior, the large interior shot should be displayed in the main image area.


END OF EXAMINATION PAPER