Está en la página 1de 16

UNIVERSITI TENAGA NASIONAL College of Information Technology

BACHELOR OF INFORMATION TECHNOLOGY (HONS.) BACHELOR OF COMPUTER SCIENCE (HONS.)

FINAL EXAMINATION SEMESTER I 2009/2010 WEB PROGRAMMING (CSEB 124)

October 2009

Time allowed: 3 hours + 10 minutes for reading

INSTRUCTIONS TO CANDIDATES 1. 2. 3. The total marks for this exam is 100 marks. There are THREE (3) SECTIONS to this paper: Section A, Section B, and Section C. Answer ALL questions in the answer booklet provided.

DO NOT OPEN THIS QUESTION PAPER UNTIL YOU ARE INSTRUCTED TO DO SO THIS QUESTION PAPER CONSISTS OF 16 PRINTED PAGES INCLUDING THIS PAGE

SECTION A: MULTIPLE-CHOICE (30 QUESTIONS, 30 MARKS) Instruction: Please select the BEST answer from the given choices.

1. Since _______ is open-source, the source code is freely available on the web, and developers can install and use it without paying licensing fees or investing in expensive hardware or software. (a) PHP (b) JavaScript (c) XHTML (d) CSS

2. Which one is the expected output of the following codes?


<html><head></head> <body> <h4>CSS stands for:</h4> <?php //print output echo '<h4><i>A: Cascading Style Sheet </i></h4>'; ?> </body></html>

(a) CSS stands for: A: Cascading Style Sheet (b) print output CSS stands for: A: Cascading Style Sheet (c) CSS stands for: <h4><i>A: Cascading Style Sheet </h4></i> (d) A: Cascading Style Sheet

3. Hyperlinks allow us to: (a) move between web pages (b) see pictures (c) insert image (d) create image map

Page 2 of 16
Semester I 2009/2010 Web Programming

4. All the following are the correct match between the data type and its example, EXCEPT: (a) Integer (b) Floating point (c) String (d) Integer $age=99; $temperature=56.89; $name=Harry; $age=-95;

5. Which one are the 3 types of CSS? (a) Internal, External and Online Style Sheets (b) Embedded, Outsider and Inline Style Sheets (c) Embedded, Linking and Inline Style Sheets (d) Internal, External and Inline Style Sheets

6. All the following are the differences between HTML and XHTML, EXCEPT: (a) In XHTML, empty elements must be closed properly (b) In XHTML, all tags must be lower case (c) In XHTML, the attribute must be upper case (d) In XHTML, all elements must be properly closed

7. ____________ is an image on a web page that is divided into shaped portions, each of which has an associated hyperlink. (a) Image map (b) Hyperlink (c) Meta tags (d) List

8. In PHP, both ________ and ________ can be used for strings. (a) hash signs (# #), double quotes ( " " ) (b) periods (. . ), double quotes ( " " ) (c) single quotes ( ' ' ), asterisk (* *) (d) single quotes ( ' ' ), double quotes ( " " )

Page 3 of 16
Semester I 2009/2010 Web Programming

9. In JavaScript, function parseInt converts: (a) String argument to an integer (b) Integer to string argument (c) String argument to float (d) Integer to float

10. The ___________ property allows a developer to layer overlapping elements. (a) v-index (b) m-index (c) x-index (d) z-index

11. The _________ is the grandparent of what is today called the Internet. (a) NSFnet (b) World Wide Web (c) Local Area Network (d) ARPAnet

12. PHP server scripts are surrounded by which delimiters? (a) <&>...</&> (b) <?php?> (c) <?php>...</?> (d) <script>...</script>

13. What is a correct way to add a comment in PHP? (a) /**/ (b) *\..\* (c) <comment></comment> (d) <!---->

Page 4 of 16
Semester I 2009/2010 Web Programming

14. Which one of these variables has an illegal name? (a) $my-Var (b) $myVar (c) $my_Var (d) $123 myVar

15. With SQL, how do you select all the records from a table named "Students" where the value of the column "FirstName" is "Johnson"? (a) SELECT * FROM Students WHERE FirstName='Johnson' (b) SELECT [all] FROM Students WHERE FirstName LIKE 'Johnson' (c) SELECT * FROM Students WHERE FirstName< >'Johnson' (d) SELECT [all] FROM Students WHERE FirstName='Johnson'

16. With SQL, how can you return all the records from a table named "Students" sorted descending by "FirstName"? (a) SELECT * FROM Students ORDER FirstName DESC (b) SELECT * FROM Students SORT 'FirstName' DESC (c) SELECT * FROM Students SORT BY 'FirstName' DESC (d) SELECT * FROM Students ORDER BY FirstName DESC

17. With SQL, how can you insert a new record into the "Students" table? (a) INSERT ('Jimmy', 'Jackson') INTO Students (b) INSERT INTO Students VALUES ('Jimmy', 'Jackson') (c) INSERT VALUES ('Jimmy', 'Jackson') INTO Students (d) INSERT INTO TABLE Students VALUES ('Jimmy', 'Jackson')

18. How can you change "Hansen" into "Sofia" in the "LastName" column in the Students table? (a) MODIFY Students SET LastName='Sofia' WHERE LastName='Hansen' (b) UPDATE Students SET LastName='Hansen' INTO LastName='Sofia' (c) UPDATE Students SET LastName='Sofia' WHERE LastName='Hansen' (d) MODIFY Students SET LastName='Hansen' INTO LastName='Sofia

Page 5 of 16
Semester I 2009/2010 Web Programming

19. With SQL, how can you return all the records from a table named "Persons" sorted ascending by "FirstName"? (a) SELECT * FROM Persons ORDER FirstName ASC (b) SELECT * FROM Persons SORT 'FirstName' ASCENDING (c) SELECT * FROM Persons SORT BY 'FirstName' DESC (d) SELECT * FROM Persons ORDER BY FirstName ASC

20. Which one of the following XHMTL tags is correct? (a) <B>Click Here</B> (b) <strong>Click Here<strong> (c) <b>Click Here</b> (d) </strong>Click Here</strong> 21. Which of these tags should NOT be located in the head section of your page? (a) <title> (b) Link to a style sheet (c) Background image (d) Metatags

22. Which heading tag will produce the largest tag? (a) <h2> (b) <h6> (c) <h5> (d) <h4>

23. Which of the following is NOT a server-side scripting? (a) PHP (b) JavaScript (c) ASP (d) ColdFusion Markup Language

Page 6 of 16
Semester I 2009/2010 Web Programming

24. All the following are browsers, EXCEPT: (a) Netscape (b) Internet Explorer (c) Mozilla (d) WAMP

25. How do you write "Hello World" in a dialog box? (a) window.alert ("Hello World"); (b) window.dialog ("Hello World"); (c) alert("Hello World"); (d) dialogBox="Hello World";

26. Where in an XHTML document is the correct place to refer to an external style sheet? (a) At the end of the document (b) At the top of the document (c) In the <body> section (d) In the <head> section

27. Which one is the expected output of the following XHTML codes?
<html><body> <table> <tr> <td>100</td><td>200</td> </tr> <tr> <td>400</td><td>500</td> </tr> </table> </body></html>

Page 7 of 16
Semester I 2009/2010 Web Programming

(a)

(c)

(b)

(d)

28. In JavaScript, if the current time is 2.00 pm, what will be the return value if function or method getHours() is performed? (a) 0200 (b) 14 (c) 200 (d) 1400

29. What would the browser display if the following script is executed? Assume that 12 and 4 are the inputs entered.
1 2 3 4 5 6 7 8 9 10 11 12 13 <html> <head> <script type = "text/javascript"> var x, y, result; var xVal, yVal; xVal = window.prompt( "Enter first integer:", "0" ); yVal = window.prompt( "Enter second integer:", "0" ); x = parseInt( xVal ); y = parseInt( yVal ); result = x % y; document.writeln( "<h1>Result= " + result + "</h1>" ); </script> </head><body></body></html>

(a) Result= 0 (b) Result= 48 (c) Result= 3 (d) Result= 0.33

Page 8 of 16
Semester I 2009/2010 Web Programming

30. All the following statements are TRUE when describing form controls, EXCEPT: (a) The difference between a group of radio buttons and a group of checkboxes is that only one radio button can be pressed at any time (b) Drop-down menu should be used if the number of possible choices is large and displayed form becomes too long to display (c) All form controls should be contained within a <method> tag (d) Label controls add descriptive text to a form to provide the user with helpful information

Page 9 of 16
Semester I 2009/2010 Web Programming

SECTION B: SHORT ANSWER QUESTIONS (7 QUESTIONS, 40 MARKS) Instruction: Answer ALL questions.

Question 1 Sketch the expected output of the following codes: (a)


<html><head></head> <body> <?php //define variable $answer= 'Elephant'; //print output echo"<h4><strike> $answer </strike></h4>"; ?> </body></html>

[2 marks]

(b)
<html><body> <style> p { color : blue } .navtext { color : black; font-weight : bold } </style> <p class="navtext" style= "color: red">Link 1</p> <p class="navtext">Link 2</p> <p class="navtext">Link 3</p> </body></html>

[3 marks]

(c)
<?php $username= 'nora'; $domain= 'example.com'; $email= $username. '@' . $domain; echo $email; ?>

[2 marks]

Page 10 of 16
Semester I 2009/2010 Web Programming

(d)
<?php $languages=array(0 => "Perl", 1 => "PHP", 2 => "Python"); $search= "PHP"; $limit= count($languages); for ($i=0;$i<$limit;$i++){ echo "<br>Testing for match with $languages[$i]"; if ($search == $languages[$i]) { echo "<br> $search is an approved language"; } } ?>

[3 marks] Question 2 Write URL address of each of the following organizations. The location is given. [6 marks] Organization King Saud University, Saudi Arabia Malaysia Aids Council Ministry of Youth and Sports, Malaysia Location ksu mac kbs URL address

Question 3 Assume there are two web pages. The first page contains the following codes that creates a new client session and register two session variables.
<?php session_start(); $_SESSION['username']= 'hello'; $_SESSION['role']= 'admin'; ?>

Page 11 of 16
Semester I 2009/2010 Web Programming

The second page contains the following codes that attempts to access the values of the session variables registered in the first page.
<?php session_start(); echo $_SESSION['username']; ?>

(a) Write the output after second page is executed. [2 marks]

(b) Does the first page print anything as the output? If yes, write the output. If no, provide a reason. [2 marks]

Question 4 Given:
<html> <head> <style type = "text/css"> span { background-color: #ffccff; font-size: 1.5em; width: 20% } p { text-align: justify } </style> </head> <span>CSEB 124</span> <p>Web Programming</p> </body></html>

Figure 1

(a) Convert CSS codes shown in Figure 1 from Internal Style Sheet to Inline Style Sheet. [4 marks]

Page 12 of 16
Semester I 2009/2010 Web Programming

(b) Write the expected output after the following user style sheet is applied to CSS codes shown in Figure 1.
userstyle.css p {background-color: yellow}

[2 marks]

Question 5 Given:
<?php $x = 1.5; settype ($x, integer); echo $x; ?>

(a) What is the output of above PHP codes? [2 marks]

(b) What is the usage of settype? [1 mark]

(c) List TWO (2) examples of PHP data types. [2 marks]

(d) Other than echo, state the other way of printing a statement in PHP. [1 mark]

Question 6 Based on what the PHP codes supposed to do, fill up the empty spaces with a correct PHP MySQL function. (a) Execute the query stored in the string variable $sql and stores the result in the variable $rset.
$rset = ________($sql);

[2 marks] Page 13 of 16
Semester I 2009/2010 Web Programming

(b) Connect to a MySQL server on the host named db, using the User ID admin and the password secret. Store the connection to database information in variable $connect_db.
$connect_db= _________(db,admin,secret);

[2 marks]

Question 7 Identify and correct the errors in each of the following segments of code. (a)
define ("INDEPENDENCEDAY", 31st August 2009); echo "Independendence Day is the ". INDEPENDENCEDAY;

[2 marks]

(b)
$words="one, two, three"; if (ereg("one", $words)echo "Found string 'one'";

[2 marks]

Page 14 of 16
Semester I 2009/2010 Web Programming

SECTION C: WRITING PROGRAMS (2 QUESTIONS, 30 MARKS) Instruction: Answer ALL questions.

Question 1 Observe the following form:


<html><head></head> <body> <form action="message.php" method="post"> Enter your name:<input type="text" name="name" size="10"><br> Choose your hobbies: <input type="checkbox" name="cbox1" value="sailing"> Sailing <input type="checkbox" name="cbox2" value="gardening"> Gardening <input type="checkbox" name="cbox3" value="rock climbing"> Rock climbing <br> <input type="submit" value="Send"></form> </body></html>

When user enters data in the above form, a PHP file named message.php should display back the data to user. Write full codes of message.php. [10 marks]

Question 2 Write PHP codes that delete information from MySQL database named dbdemo. You may need two files where the first file creates connection to database, selects database, executes query and provides a simple form that contains drop-down list box and delete button. When user clicks at the drop-down list box options, they should be able to see a list of name, extracted from column name from table biodata. Your second file should also contain PHP codes that creates connection to database, selects database and executes query. However, this time the program (through SQL query) should be able to delete the data based on the chosen name, displayed by dropdown list box created before. The databases username is root, no password and running on localhost. Refer to Figure 2 for sample of form and Table 1 for sample of database.

Page 15 of 16
Semester I 2009/2010 Web Programming

Figure 2

Table 1

[20 marks]

-- End of Questions --

Page 16 of 16
Semester I 2009/2010 Web Programming

También podría gustarte