Internet Programming and Applications - Exam

UNIVERSITY OF DODOMA

ACADEMIC YEAR 2020/2021

UE Paper


SECTION A: (15 MARKS)

Question One: Multiple Choice

i. Which tag is used to display text in title bar of a web document?
(0.5 Marks)

  • A. Body tag
  • B. Meta tag
  • C. Title tag
  • D. Comment tag
  • E. Head tag

ii. Which tag is used to identify the keywords describing the site?
(0.5 Marks)

  • A. Comment tag
  • B. Title tag
  • C. Meta tag
  • D. Anchor tag
  • E. Heading tape

iii. Which property of a page element (eg a div) is used by JavaScript to alter the content of a page after it has loaded?
(0.5 Marks)

  • A. value
  • B. text
  • C. firstChild
  • D. innerHTML
  • E. style

iv. Which is the correct way to link to an external stylesheet from a web page?
(0.5 Marks)

  • A. <link rel = "stylesheet" type = "text/css" src = "styles.css" />
  • B. <link rel = "stylesheet" type = "text/css" href = "styles.css" />
  • C. <style href = "styles.css" type = "text/css" />
  • D. <style> div{color: blue;} </style>
  • E. <a href = "stylesheet" type="text/css"></a>

v. Which JavaScript function is used to open a small window for user input?
(0.5 Marks)

  • A. alert()
  • B. prompt()
  • C. document.write()
  • D. init()
  • E. confirm()

vi. jQuery is a:
(0.5 Marks)

  • A. JavaScript Library
  • B. JavaScript Language
  • C. JavaScript Method
  • D. PHP Method
  • E. JavaScript function

vii. Which sign does jQuery use as a shortcut for jQuery?
(0.5 Marks)

  • A. the % sign
  • B. the ? Sign
  • C. the $ sign
  • D. the #sign
  • E. the // sign

viii. $(document).ready(function() { // Some code. }); The above code is used to:
(0.5 Marks)

  • A. Make sure no code is executed till the entire page is fully loaded
  • B. Make sure no code is executed till the DOM is fully loaded
  • C. Make sure no browser will open till the DOM is fully loaded.
  • D. Both A and B
  • E. Make sure no function will execute till the entire page is loaded.

ix. Which property in JavaScript would you use to redirect visitor to another page?
(0.5 Marks)

  • A. window.location.href
  • B. document.href
  • C. java.redirect.url
  • D. link.redirect.href
  • E. document.findElementById()

x. Which of the following jQuery method is used to attach a handler to an event?
(0.5 Marks)

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

Question Two: Matching

HTML5 introduces a number of new elements and attributes tag: help in building a modern website. Match the HTML5 element in Column A with its corresponding description in Column B. (0.5 Marks Each)

Column AColumn B
I. SectionA. This tag can be used to associate a caption together with some embedded content, such as a graphic or video.
II. ArticleB. Represents a measurement, such as disk usage.
III. AsideC. Improve the performance of our websites by avoiding the need to download images off the network.
IV. HeaderD. Element represents a run of text in one document marked or highlighted for reference purposes.
V. FooterE. This tag represents a generic document or application. It can be used together with labels to indicate the document structure.
VI. NavF. This tag can be used to mark up a conversation.
VII. FigureG. This tag represents a section of the document intended for naviagation.
VIII. MarkH. This tag contain information about the author, copyright information, etc.
IX. CanvasI. Defines a video file.
X. MeterJ. Represents some type of output, such as from a calculation done through scripting.
K. This tag represents the header of a section.
L. This tag represents an independent piece of content of a document, such as a blog entry or newspaper.
M. This tag represents a piece of content that is only slightly related to the rest of the page.

Question Three: Short Answer

i. What HTML tag is used to insert a copyright symbol in a web page?
(1 Mark)

ii. How do we comment HTML code in an HTML page?
(1 Mark)

iii. Why do we need to mention <!DOCTYPE HTML> at the beginning of an HTML page?
(1 Mark)

iv. Which html tag is used to produce a horizontal line on a webpage?
(1 Mark)

v. Why do we need to include an alt attribute on img tags?
(1 Mark)


SECTION B: (45 MARKS)

Question Four: Exam Results Analysis

College of Natural and Mathematical Sciences (CNMS) offers a course that prepares students in improving skills of research into different statistical techniques applied during data processing, analysis and practical interpretation of the result. Last year, several students who completed this course took the final exam. Naturally, the college wants to know how well its students performed. You have been asked to write a program (using Javascript and HTML) to summarize the result. You have been given a list of 10 students, next to each name is written 1 if the student passed the exam or 2 if the student failed.

Your program should analyse the results of the exam as follows:

(1) Input each test result (i.e., a 1 or a 2). Display the message “Enter result” each time the program requests another test result. (2) Count the number of test results of each type. (3) Display a summary of the test results indicating the number of students who passed and the number of students who failed.

(4) If more than eight students passed the exam, print the message “Raise tuition”.
(15 Marks)


Question Five: University Feedback Form

The University of Dodoma has asked you to create a program that allows prospective students to provide feedback about their campus visit. Your program should contain a form with text boxes for name, address and email. Provide checkboxes that allow prospective students to indicate what they liked most about the campus. The checkboxes should include: students, location, campus, atmosphere, dorm rooms and sports. Also, provide radio buttons that ask the prospective student how they became interested in the university. Options should include: friends, television, Internet and other. In addition, provide a text area for additional comments, submit and reset buttons and JavaScript function to validate each form field. The JavaScript validation should consider both form and data validation. (15 Marks)


Question Six: CSS Rules

By referring to CSS, accomplish the following

i. Write a CSS rule that makes all text 1.5 times larger than the base font of the system and color the text red.
(3 Marks)

ii. Write a CSS rule that places a background image halfway down the page, tiling it horizontally. The image should remain in place when the user scrolls up or down.
(3 Marks)

iii. Write a CSS rule that gives all h1 and h2 elements a padding of 0.5ems, dashed border style and a margin of 0.5 ems.
(3 Marks)

iv. Write a CSS rule that changes the color of all elements containing attribute class=“green-Move” to green and shift them down 25 pixels and right 15 pixels.
(3 Marks)

v. Write a layout template that contains a header and two columns. Use divs 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 where your divs are.
(3 Marks)


Question Seven: jQuery Operations

a. Document Object Model (DOM) manipulation is so common with JavaScript, and because the JavaScript to do so can get quite lengthy, people wanted alternatives. One of the alternative is to use jQuery library. Change the following DOM statements to jQuery statements. (3 Marks Each)

i. document.getElementById('colorDiv').style.backgroundColor = 'green'
(3 Marks)

ii. document.getElementById("myImage").src = "landscape.jpg";
(3 Marks)

b. You have a CSS file called “myCss.css” as seen in the code snippet below, that defines the styles for various CSS classes, including a class named “large”. You also have an HTML element with the class “center” as seen in the code snippet below. Your task is to write a jQuery statement(s) that will change the style of the element with the class “center” to match the style of the “large” class as defined in the “myCss.css” file.

(4 Marks)

myHtml.html
    <!DOCTYPE html>
    <html>
    <head>
    <script src="myjQuery.js"></script>
    <meta charset="utf-8">
    <meta name="viewport"content="width=device-width">
    <title>Change a CSS class name using jQuery.</title>
    </head>
    <body>
    <p id ="pid" class="center"> jQuery
    Exercise</p>
    <input id="button1" type="button" value="Click to change the Class" />
    </body>
    </html>

myCss.css
p.center {
    text-align: center;
    color: red;
}
p.large {
    font-size: 200%;
}

ii. Consider the code segment below, write a jQuery statement(s) that will change the url property of element with class=“link” from http://example.com to http://cp221.com (4 Marks)

    <!DOCTYPE html>
    <html>
    <head>
    <script src="myjQuery.js"></script>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <title>JS Bin</title>
    </head>
    <body>
    <a class="link"
    href="http://example.com">Visit
    wiresources/ap
    <p><input id="button1" type="button"
    value="Click to see the actual url"/></p>
    </body>
    </html>

iii. Consider the code segment below. Write a jQuery statement(s) to get the value of the textbox with property “type=text”. (4 Marks)

<!DOCTYPE html>
<html>
<head>
<script src="myjQuery.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>How to get the value of a textbox using jQuery</title>
</head>
<body>
<input type="text" value="Input text here"/>
</body>
</html>

END OF EXAMINATION PAPER