You are on page 1of 6

Kingdom of Saudi Arabia

Ministry of Education ‫اﻟﻤﻤﻠﻜﺔ اﻟﻌﺮﺑﯿﺔ اﻟﺴﻌﻮدﯾﺔ‬


Prince Sattam Bin Abdulaziz ‫وزارة اﻟﺘﻌﻠﯿﻢ‬
University ‫ﺟﺎﻣﻌﺔ اﻻﻣﯿﺮ ﺳﻄﺎم ﺑﻦ ﻋﺒﺪ اﻟﻌﺰﯾﺰ‬
College of Computer ‫ﻛﻠﯿﺔ ھﻨﺪﺳﺔ وﻋﻠﻮم اﻟﺤﺎﺳﺐ‬
Engineering and sciences ‫ﻗﺴﻢ ﻋﻠﻮم اﻟﺤﺎﺳﺐ‬
Department of Computer Science
Course Title: CS3821- Web
Applications Programming
CS3821 ................ : ‫ﺷﻌﺑﺔ رﻗم‬
Second Exam
Instructor Name:
1438/1439 (II) : ‫اﻟطﺎﻟﺑﺔ‬/‫اﺳم اﻟطﺎﻟب‬
(Answer Key)
Date: 18/04/2018
:‫اﻟرﻗم اﻟﺟﺎﻣﻌﻲ‬
Time: 1 hour

Instructions ‫ﺗﻌﻠﯿﻤﺎت‬
 This exam consists 4 questions on 6 pages 6 ‫ اﺳﺌﻠﺔ ﻣﻮزﻋﺔ ﻋﻠﻰ‬4 ‫ھﺬا اﻻﻣﺘﺤﺎن ﻣﺆﻟﻒ ﻣﻦ‬ 
 All questions should be answered on the same ‫ﺻﻔﺤﺎت‬
sheets
‫ﺟﺎوب ﻋﻠﻰ ﺟﻤﯿﻊ اﻷﺳﺌﻠﺔ ﻋﻠﻰ ﻧﻔﺲ اﻻوراق‬ 
 Electronic devices that could have a memory
is not allowed ‫ﯾﻤﻨﻊ اﺳﺘﻌﻤﺎل اﻻﺟﮭﺰة اﻻﻟﻜﺘﺮوﻧﯿﺔ اﻟﺘﻲ ﺗﺤﺘﻮي ﻋﻠﻰ‬ 
 Traditional calculator is allowed ‫ذاﻛﺮة‬
 Examination rules must be adhered to. ‫ﯾﻤﻨﻊ اﺳﺘﻌﻤﺎل اﻻﻟﺔ اﻟﺤﺎﺳﺒﺔ‬ 
 Books or other related materials are NOT .‫ﯾﺠﺐ اﻻﻟﺘﺰام ﺑﺠﻤﯿﻊ ﻗﻮاﻧﯿﻦ وﻟﻮاﺋﺢ اﻻﻣﺘﺤﺎﻧﺎت‬ 
‫ﻻ ﯾﺴﻤﺢ ﺑﺎﻟﻜﺘﺐ أو اﻟﻤﻮاد ذات اﻟﺼﻠﺔ داﺧﻞ ﻏﺮﻓﺔ‬ 
allowed ‫اﻻﻣﺘﺤﺎن‬

For Official Use Only


First Marking Second Marking
Course
Questio Max
Outcom Grade Instructor’s Signature Grade Second Signature
n No. Score
e
Q1 CLO#1 5 + (1B)
Q2 CLO#3 5
Q3 CLO#4 5
Q4 CLO#2 (1B)
Total
15
Marks

Exam Score =
Exam Score in words:

Page 1 of 6 CS2301 – Web Applications Programming – Second Exam Semester 2 - 1438-39H


Q1: Circle the correct answer (5 marks +1)

1.When using the box model, the _____ is always transparent.


A. border
B. content
C. spacing
D. margin

2. Which of the following configures a 1 pixel, solid black border for an element?
A. border-all: #000000;
B. border: 1px solid #000000;
C. border-style: 1px solid #000000;
D. border-top: 1px solid #000000;

3.The _______ is the area between the content and the border.
A. border
B. spacing
C. padding
D. margin

4.When configuring the background color of an element, the background color is applied to both the content
and ______ areas.
A. border
B. padding
C. margin
D. extra
5. The purpose of the ________ element is used for section of navigation of a web page.
A. header
B. nav
C. main
D. content

6. Select an advantage of displaying HTML5 video in a web page from the list below:
A. You need to create multiple video files in different formats.
B. No browser plug-in or player is needed.
C. All browsers play all video formats.
D. All of the above are advantages.

7. JavaScript can be described as:


A. an interpreted and dynamically typed
B. an easy form of Java
C. a language created by Microsoft
D. support class-based inheritance
8. Which method will retrieve the contents of an HTML element?
A. document.get()
B. getElementById()
C. innerHTML
D. document.innerHTML

Page 2 of 6 CS2301 – Web Applications Programming – Second Exam Semester 2 - 1438-39H


9. Which of the following will prompt the user to enter his or her name?
A. var name = window.open("What is your name?");
B. prompt("What is your name?", name);
C. var name = document.write("What is your name?");
D. var name = prompt("What is your name?");

10. A PHP script should start with ___:


A. < php
B. < ?php
C. <?
D. < ?php? >

11. Which of the following PHP statements will output Hello World on the screen?
A. echo (“Hello World”);
B. println (“Hello World”);
C. scanf(“Hello World”);
D. sprintln(%s,”Hello World”);

12. What will be the output of the following PHP code?


< ?php $a = "clue"; $a .= "get"; echo "$a"; ?>
A. get
B. true
C. false
D. clueget

Q2: JavaScript Program (5 marks)


Write a JavaScript program which illustrates the Switch case example:

Instance variable: (figure 1 – a)


N: variable inputted by the dialog box prompt with a default message “Enter a number between 1 and 7”.

Output: (figure 1 – b)
The name of the day with the use of the method write as shown in the following table.

1 Sunday
2 Monday
3 Tuesday
4 Wednesday
5 Thursday
6 Friday
7 Saturday
N not between 1 and 7 Invalid Weekday

Page 3 of 6 CS2301 – Web Applications Programming – Second Exam Semester 2 - 1438-39H


(a) (b)
Figure 1

<script type="text/javascript">
var N=prompt("Enter a number between 1 and 7"); (0.5 marks)

switch (N) (0.5 marks)


{
case (N="1"): (0.5 marks)
document.write("Sunday");
break;

case (N="2"): (0.5 marks)


document.write("Monday");
break;

case (N="3"): (0.5 marks)


document.write("Tuesday");
break;

case (N="4"): (0.5 marks)


document.write("Wednesday");
break;

case (N="5"): (0.5 marks)


document.write("Thursday");
break;

case (N="6"): (0.5 marks)


document.write("Friday");
break;

case (N="7"): (0.5 marks)


document.write("Saturday");
break;
default: (0.5 marks)
document.write("Invalid Weekday");
break;
}
</script>

Page 4 of 6 CS2301 – Web Applications Programming – Second Exam Semester 2 - 1438-39H


Q3: PHP program (5 marks)

Write a complete PHP code (figure 2):


1. Print an array of elements from 1 to 15
2. Counts and prints how many odd elements that array has.
3. Counts and prints how many even elements that array has.

Figure 2

<?php

$list = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15); 0.5 marks

$OddCounter=0; 0.5 marks

$EvenCounter=0; 0.5 marks

echo "Array Elements are :"; 0.25 marks

foreach($list as $element){ 0.5 marks

echo ($element. " ");0.25 marks

if ($element%2==0) 0.5 marks

$EvenCounter++;0.5 marks

else

$OddCounter++; 0.5 marks

}
echo "<br>Number of Odd Elements ="; 0.25 marks

echo $OddCounter; 0.25 marks

echo "<br>Number of Even Elements ="; 0.25 marks

echo $EvenCounter; 0.25 marks

?>
Page 5 of 6 CS2301 – Web Applications Programming – Second Exam Semester 2 - 1438-39H
Q4: HTML5 program (1 marks)
Write a complete HTML5 code to display the following video as shown in the figure 3. The video source
named movie.mp4 with height="240" width="320". A massage “Your browser does not support the video
tag” will appear if the browser cannot support video.

Figure 3

<!DOCTYPE html> 0.25 marks

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

</head>

<body>

<video width="320" height="240" controls="">0.25 marks

<source src="movie.mp4" type="video/mp4">0.25 marks

Your browser does not support the video tag 0.25 marks

</video>

</body>

</html>

Page 6 of 6 CS2301 – Web Applications Programming – Second Exam Semester 2 - 1438-39H

You might also like