0% found this document useful (0 votes)
40 views17 pages

2017 - HNDIT2413 - Web Application DevelopmentAnswers

Uploaded by

yogefe4885
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views17 pages

2017 - HNDIT2413 - Web Application DevelopmentAnswers

Uploaded by

yogefe4885
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

[All Rights Reserved]

SLIATE
SRI LANKA INSTITUTE OF ADVANCED TECHNOLOGICAL EDUCATION
(Established in the Ministry of Higher Education, vide in Act No. 29 of 1995)

Higher National Diploma in Information Technology


Second Year, Second Semester Examination – 2017
HNDIT2413 – Web Application Development

Instructions for Candidates: No. of questions : 06


Answer five (05) questions. No. of pages : 08
All questions carry equal marks. Model Answers Time : Three (03) hours

1)
i. What does WWW stand for? Define it. (02 marks)

ANSWER
 World Wide Web (01 Mark)

 Definition: (01 Mark)


One of the main service provided by the internet
A system of interlinked hypertext documents accessed via the Internet

ii. Write HTML codes to create following table by considering the given formatting.
Table caption : Student Marks
Table alignment : Center (horizontally)
Table header rows : Shaded in blue (10 marks)

Student Marks

Subject
Student Total
IT English
A 19 39

B 19 39

ANSWER
<TABLE border=1 cellspacing="0" align="center" width="25%">

<caption><b>Student Marks</b></caption>

<tr bgcolor="blue">
1
<th rowspan="2">Student</th>
<th colspan="2">Subject</th>
<th rowspan="2">Total</th>
</tr>
<tr bgcolor="blue">
<th>IT</th>
<th>English</th>
</tr>

<tr align="center">
<td>A</td>
<td>19</td>
<td>39</td>
<td></td>
</tr>

<tr align="center">
<td>B</td>
<td>19</td>
<td>39</td>
<td></td>
</tr>
</table>

iii. Differentiate between web browser and search engine and give examples for each. (04 marks)

ANSWER
A software application for retrieving, presenting, and traversing information resources on the
World Wide Web where as search engine is a software system that is designed to search for
information on the World Wide Web

web browser : Internet Explorer, Firefox, Google Chrome, Apple Safari, and Opera.
search engine : Google,Bing,Yahoo,Ask.com,AOL.com,Baidu,Wolframalpha,DuckDuckGo.

iv. Explain the Client Server Architecture (04 marks)

ANSWER
• Client-server architecture (client/server) is a network architecture in which each computer
or process on the network is either a client or a server
• The client is defined as the requester of services and the server is defined as the provider
of services
• A Server a host that is running one or more server programs which can be sharing of
information or resources
• Client does not share any of its resources, but requests a server's content or service function.

2
(Total 20 marks)

2)
i. What does CSS stand for? Mention 02 ways of inserting CSS in a web page. (02 marks)

ANSWER
Cascading Style Sheet
• Inline CSS
• Internal CSS
• External CSS

ii. List down three differences between Internal CSS and External CSS. (03 marks)

ANSWER
Internal External
Defined inside <style> elements. Linked via the <link
rel="stylesheet"> element.

Embedded directly inside the page. Exists as a separate file linked to website.

Can be applied to one page only Can be applied to several pages


browser doesn't need to make an browser need to download the .css file
additional GET request to download the
.css file

iii. What are the advantages of using CSS for a web site (03 marks)

ANSWER
 Can control the style of many different elements with a single command.
 Separation of function: HTML can focus on content while CSS handles styling.
 Save more time by reducing repetitive works
 Maintain the consistency of web site

iv. The following banner is created by using a Banner,html.

(12 marks)
3
Fill in the blanks of the following banner.html which is created by using the following
instructions.
Instructions for a formatting:
 Technosoft banner has a background color, a border and a exact width and height
 Banner header (“TechnoSoft 2017 SOFTWARE COMPETITION”) text is in blue
color and has a background color
 “On 18th and 19th January 2018” is a bold text in red color.

Banner.html
<html>
<head>
< (1) type="text/css">
h3{
(2) :blue;
(3) :verdana;
…..(4)……: #abfae1;
text-align:….(5)…..;
}

p{
…..(6) :12px;
text-align:center;
}

Div.container{
……(7)…..:300;
Height:250;
…..(8)…..: 3px solid;
……(9)……: #fafbe5;
}

4
ul{
…..(10)…..:square;

}
</style>
</head>
<body>
<div class="container">
<h3> TechnoSoft 2017 <br> SOFTWARE COMPETITION</h3>
<p> Inter ATI, University, Higher Education Institutes and School</p>
<ul>
<li>Software Competition</li>
<li>Exhibition</li>
<li>Gaming Competition</li>
</ul>

<div ……(11)….="color:red; ….(12)…..:bold; text-align:center;">On 18th and 19th


January 2018<br>
at ATI Gampaha</p></div>
</div>
</body>
</html>

ANSWER
1. style
2. color
3. font-family
4. background-color
5. center
6. font-size
7. width
8. border
9. background-color
10. list-style-type
11. style
12. font-weight
(01 marks x 12)

(Total 20 marks)

5
3)
i. Differentiate between Static and Dynamic websites. (02 marks)

ANSWER

Static websites Dynamic websites


do not change the content or layout adapt their content depending on user
depending on user input input or computing environment
usually written in plain HTML written using a server-side scripting language such as PHP,
ASP, JSP
Quick to develop Take time to develop
Cheap to develop more expensive to develop
Cheap to host Hosting costs a little more
Requires web development expertise to Much easier to update
update
Not much functional website as a dynamic Much more functional website
Speed Slower

ii. Define and give two examples for each; (04 marks)
a. client-side scripting
b. Server-side scripting

ANSWER
client-side scripting :
The source code is transferred from the web server to the users computer over the
internet and run directly in the browser.

JavaScript ,VBScript ,HTML ,CSS,AJAX ,jQuery etc.

Server-side scripting:
runs a scripting language is a web server.
A user's request is fulfilled by running a script directly on the web server to generate
dynamic HTML pages.

PHP ,ASP.NET,C++ ,Java and JSP ,Python ,Ruby

iii. Write the output of following JavaScript codes


a.
<script language="javascript" type="text/javascript">
for(i=1;i<9;i++) {
if(i==4) Continue;
document.write(i);
}
</script> (02 marks)

6
ANSWER
1235678

b.
<script language="javascript" type="text/javascript">
var x="Welcome you all";
document.write(x);
document.write("<br>");
document.write(x.length+"<br>");
document.write(x.toUpperCase());
document.write("<br>");
document.write(x+=" to 2018");
</script> (04 marks)
ANSWER

iv. Write a html program to create the form and JavaScript function to check the
following.
 Only numbers between 1 and 100 can be inserted. When an invalid number is
entered, the message must be appeared as “Invalid input”. If it is a valid
number, the message must be appeared as “Valid input”.
 The function should be called on the button “Validate”.

Text box Button

ANSWER
<html>
<head>
<script>
function validateForm() {
var x =myForm.fname.value;
if (x<1 || x>100) {
alert("invalied number ");}
else
{
alert("invalied number ");

}}</script> [04 Marks]

7
</head>
<body>
<form name="myForm" >
Enter NUMBER: <input type="text" name="fname"><br>
<input type="button" value="Submit" onclick="validateForm();">
</form>
</body>

</html>
[04 Marks]
(Total 20 marks)

4)
i. What does PHP stand for and the latest version of PHP? (02 marks)

ANSWER
Hypertext Preprocessor

PHP 7 version

ii. What is the difference between “Switch” and “If” Statements (02 marks)

ANSWER
The if statement uses a Boolean expression to execute the function and can often be used
to check multiple conditions at a time. but switch evaluates only one expression, executing
different code according to the result of that expression, as long as the expression evaluates
to a simple type (a number, string, or Boolean).

8
iii. Write the output of following PHP codes
a.
[02 Marks]
<?php
$color = "red";
echo "My car is " . $color . "<br>";
echo "My house is " . $COLOR . "<br>";
echo "My boat is " . $coLOR . "<br>";
?>

ANSWER

My car is red
My house is
My boat is

b. c.
<?php <?php
$first = array("a", "b", "c"); function add_subt($val1,$val2){
$second = array(1,2,3); $add = $val1 + $val2;
$third = array_merge( $first, $second ); $sub = $val1 - $val2;
foreach ( $third as $val ) $result = array ($add,$sub);
{ return $result;
print "$val<BR>"; }
}?> $func_result = add_subt(12,5);
ANSWER
echo “Add: “. $func_result [0].”</br>”;
abc123
echo “Subt: “. $func_result [1].”</br>”;

?>

ANSWER

Add:17
Subt:7

[03 Marks]

[03 Marks]

9
d. Write a php code segment to create an array which should hold the student’s name and
their age as the given below.
Saman 18
Kasun 20
Nisal 23
Kamal 25 (03 marks)

ANSWER
<?php
$person=array(“Saman”=>18,“Kasun”=>20,“Nisal”=> 23, “Kamal”=>25);

Foreach($person as $key=>$value){

Print $key.” “.$value.”<br>”;

?>

e. Write a proper PHP statement to generate the decision of wrist watch for a given price.

Price criteria Decision


<=1000 Low Price
<=5000 Average Price
>5000 High Price (04 marks)

ANSWER
<?php
$x = 2850;

if ($x <=1000) {
echo "Low Price ";
}else if($x<= 5000) {
echo "Average Price";
}else {
echo “High Price";
}
?>

10
HNDIT 2 Web Application Development- 2017 -2nd semester
(Total 20 marks)

11
HNDIT 2 Web Application Development- 2017 -2nd semester
5)
i. Define a cookie. (02 marks)

ANSWER
A small text file (up to 4KB) created by a website that is stored in the user's computer either
temporarily for that session only or permanently on the hard disk (persistent cookie). Cookies provide
a way for the website to recognize you and keep track of your preferences.

ii. “PHP is an open source software”. Justify your answer. [04 Marks]

ANSWER
PHP is an open source software.
 no warranty, no limits on usage

 Source code is available for any modifications


 Freely Extended (must share source, represent original works and owners)

 License is not specific to a product or restrict other software and also technology
neutral.

iii. Consider the following form.

12
HNDIT 2 Web Application Development- 2017 -2nd semester
a. Write a html program to create the above form. [08 Marks]

ANSWER
<html>
<body>
<form method="post" action="student.php" >
<table>
<tr>
<td>Student Reg. No. </td>
<td>:&nbsp <input type="text" name="stuRegNo" ></td>
</tr>

<tr>
<td>Student Name </td>
<td>:&nbsp <input type="text" name="stuName" ></td>
</tr>
<tr>
<td>Subjects: </td><br>
<tr><td> PC Application </td>
<td>: <input type="text" name="pcApp" </td></tr>
<tr><td>&nbsp &nbsp &nbsp DBMS </td>
<td>:& <input type="text" name="dbms" </td>
</tr>

<tr>
<td> Web Development </td>
<td>:&nbsp <input type="text" name="webDev" </td>
</tr>

<tr>
<td>&nbsp &nbsp &nbsp Computer Hardware </td>
<td>:&nbsp <input type="text" name="comHW" </td>
</tr>
<tr>
<td><center><input type="submit" name="submit" value="Submit" ></center></td>
</tr>
</table>
</form></body></html>

13
HNDIT 2 Web Application Development- 2017 -2nd semester
[08 Marks]
b. “When you Click the submit button that should be displayed the student name, total
mark and the average mark.”
Write a PHP program to display the above result. [05 Marks]

ANSWER
Student.php
<?php
$total =$_POST['pcApp']+$_POST['dbms']+$_POST['webDev']+$_POST['comHW'];
$average = $total / 4.0;

Echo “Student Name:”.$_POST[‘stuName’].”<BR>”;


Echo “Total Marks:”.$total.”<br>”;
Echo “Average Marks:”.$average;
?>

(Total 20 Marks)

14
HNDIT 2 Web Application Development- 2017 -2nd semester
6) This form is used to store marks of the students in ABC Institute.

This form is used to store student marks of ABC Institute


 DBMS : MySQL
 Web Programing Language : PHP
 Database Server : localhost
 User Name : Manager
 Password : abc123
 Database Name : abcStudent
 Table Name : marks

Form contains bellow text boxes


Text box Name
Student Reg, No stuRegNo
Student Name stuName
PC Application pcApp
DBMS dbms
Web Development webDev
Computer Hardware comHW

15
HNDIT 2 Web Application Development- 2017 -2nd semester
Write PHP code fragment to do the following.
i. Create the connection to MySQL Database. (04 marks)

ANSWER
$conn = mysql_connect("localhost", "Manager", "abc123");
if (!$conn)
die('Could not connect: ' . mysql_error());

ii. Insert the above data set in the form to the marks table.
[Hint: Marks (stno, stname, sb1, sb2, sb3, sb4)]
(05 marks)

ANSWER
$a= $_POST[“stuRegNo”];
$b= $_POST[“stuName”];
$c= $_POST[“pcApp”];
$d= $_POST[“dbms”];
$e= $_POST[“webDev”];
$f= $_POST[“comHW”];

$q1=”INSERT INTO marks VALUES(‘$a’,’$b’,$c,$d,$e,$f)”;


mysql_query($q1);

iii. Change the Student name to “K.K. sumith” of whom Reg. No. is “STU_0015” (05 marks)

ANSWER
$q2= “UPDATE marks SET stuName=’ K.K. sumith’ WHERE stuRegNo=’ STU_0015’ ”;
mysql_query($q2);

16
HNDIT 2 Web Application Development- 2017 -2nd semester
iv. Show all details of STU_0005 in the form (06 marks)

ANSWER
$q3= “SELECT * FROM marks WHERE stuRegNo=’ STU_0015’ ”;
$result = mysql_query($q3);

While($row=mysql_fetch_array($result))
{

echo “Reg Number :”. $row[“stuRegNo”].”<br>”;


echo “Name :”. $row[“stuName”].”<br>”;

echo “PC App marks :”. $row[“pcApp”].”<br>”;


echo “DBMS marks :”. $row[“dbms”].”<br>”;

echo “Web Development marks :”. $row[“webDev”].”<br>”;


echo “Hardware marks :”. $row[“comHW”].”<br>”;

(Total 20 marks)

17
HNDIT 2 Web Application Development- 2017 -2nd semester

You might also like