Internet Programming and Applications - Exam

UNIVERSITY OF DODOMA

COLLEGE OF INFORMATICS AND VIRTUAL EDUCATION ACADEMIC YEAR 2024/2025


SECTION A: (40 MARKS)

Attempt ALL questions in this section

Question One

Fill in the blanks with the correct answer.
(1 Mark Each)

a. In HTML, the tag used to create a hyperlink is called ______.

b. The jQuery method used to retrieve the value of an input field is called ______.

c. To create a list that does not have numbers, you use the ______ tag.

d. To center a block element, you can set its margins to ______.

e. A ______ is a collection of properties and methods in JavaScript.

f. To make a responsive design, you can use ______ queries.

g. In JavaScript, the ______ operator checks for both value and type equality.

h. To create an animation in jQuery, you can use the ______ method.

i. The ______ function in JavaScript can be used to loop through arrays.

j. The ______ method is used to remove an element from the Document Object Model (DOM) in jQuery.


Question Two

a. Outline three (3) places where you can put your JavaScript code during creation of a web page.
(3 Marks)

b. In most websites, HTML, CSS and JavaScript are normally used. Explain each and emphasising on the purpose of their use in a web page.
(6 Marks)

c. Outline three (3) ways in which CSS can be integrated into a web page.
(3 Marks)

d. Write a JavaScript code that displays the message in Figure 1 and gives an alert if a user clicks a button (click me). Feel free to put any message on the alert.
(3 Marks)


Question Three

Write true for the correct and false for the incorrect statement.
(1 Mark Each)

a. In jQuery, $(document).ready() is used to run code when the DOM is fully loaded.

b. In CSS, the margin property controls the space inside an element.

c. In JavaScript, undefined is a data type.

d. The <canvas> element is used for drawing graphics on the web page.

e. jQuery can be used to create AJAX applications.

f. The float property can be used to create multi-column layouts.

g. jQuery is a replacement for JavaScript.

h. Pseudo-classes are used to define the state of an element, such as :hover.

i. Regular expressions (Regex) can be used for string validation in JavaScript.

j. The serialize() method is used to convert form data into a URL-encoded string.


Question Four

Choose the most correct answer and write its letter in the answer booklet provided.
(1 Mark Each)

i. What does SEO stand for? A. Standardized Encoding Optimization
B. Search Engine Optimization
C. Semantic Element Organization
D. Simple Element Operation

ii. What is the purpose of the doctype declaration in HTML? A. To define the character set
B. To specify the HTML version being used
C. To link CSS files
D. To include JavaScript

iii. Which selector would you use to target an element with a specific class? A. #className
B. .className
C. element.className
D. className

iv. Which of the following correctly represents an object in JavaScript? A. {name: “John”, age: 30}
B. [“John”, 30]
C. “name: John, age: 30”
D. name = “John”, age = 30

v. What will the following code return? Math.random()? A. A random integer
B. A random float between 0 and 1
C. A random float between 1 and 10
D. A fixed number


SECTION B: (60 MARKS)

Attempt any THREE (3) out of FOUR (4) questions provided.

Question Five

You have been tasked with creating a web application designed to collect information about participants interested in joining a community gardening initiative. This application will gather essential details for each gardener, including their first name, surname, email address, and phone number. During the development process, the client requested an additional feature to capture information about the gardener’s plot. Specifically, the application should determine if the plot is for a single type of plant or for multiple types. If the plot is for a single type of plant, the application must capture the type of plant and the expected yield. Conversely, if the plot is for multiple types of plants, the application should allow the user to specify the number of different plants and, for each type, record the type of plant and the expected yield. You are required to use HTML and jQuery to design a dynamic form that adjusts based on the user’s input regarding the number of different plants. For example, if the number of plants is three, the form should display three sets of input fields for the type of plant and expected yield. (20 Marks)


Question Six

You have been hired by a local event organiser to develop a simple Event Registration Page for an upcoming tech seminar. The page should allow users to enter their full name, email address, and select their preferred session (either “Morning” or “Afternoon”) using a drop-down list. You are required to use HTML to structure the form, including appropriate input fields and a submit button. Using CSS, style the form so that it is centred on the page, with clear spacing, borders around input fields, and a submit button that changes colour when hovered over. Implement JavaScript validation to ensure that all fields are filled and that the email address is in a valid format. If validation fails, display an appropriate error message below the form. Using jQuery, enhance the functionality so that when the form is successfully submitted, it hides the form and displays a personalised thank-you message including the user’s name and selected session. Apply a fade-in animation to the thank-you message using jQuery effects. You may organize your code using inline or external styles and scripts as needed. (20 Marks)


Question Seven

You are tasked with designing a simple online shopping cart interface for a local bookstore’s website. The page should display a list of three books, each with a title, price, and an “Add to Cart” button. Using HTML, structure the book list and include appropriate elements to display the information. With CSS, make the list visually appealing by adding borders, spacing, and hover effects on the buttons. Using JavaScript, maintain a count of how many items have been added to the cart and the total price. Each time a user clicks “Add to Cart”, the item should be counted and the total updated. Display the current item count and total amount dynamically on the page. With jQuery, implement a feature that highlights the newly added book for a few seconds using an animation (such as fading or sliding). Additionally, include a “Clear Cart” button that resets the count and total, and use jQuery to animate the clearing action. (20 Marks)


Question Eight

You have been hired by a small indie game studio to create a web-based mini-game as part of an online campaign to promote their upcoming product. The client is looking for a simple yet interactive browser game that can engage users for a short period of time. Your task is to design and develop a basic “Whack-a-Mole” game using HTML, CSS, and jQuery. The game should feature a 3x3 grid, totaling nine holes, where a “mole” randomly appears. Use HTML to create the structure of the grid and the necessary interface elements, such as buttons and score display. CSS should be used to style the game board, the mole, and include animations for visual appeal. The gameplay involves the mole appearing randomly in different holes every 1 to 2 seconds. When a user clicks on the mole, their score should increase by one. jQuery must be used to control the timing of the mole’s appearance, animate interactions, and handle click events to update the score. Additionally, include a visible score counter and a countdown timer (for example, 30 seconds) on the screen. When the timer runs out, the game should display the final score and a “Play Again” button to restart the game. For an optional challenge, you can add difficulty levels (Easy, Medium, Hard) that modify the mole’s speed, and include sound effects when the mole is hit. You are expected to submit a fully functional HTML page with either embedded or linked CSS and jQuery. The game should offer a user-friendly interface and smooth gameplay experience. Ensure that your code is well-commented to explain the main logic and functionalities. (20 Marks)


END OF EXAMINATION PAPER