2017 - HNDIT2413 - Web Application DevelopmentAnswers
2017 - HNDIT2413 - Web Application DevelopmentAnswers
SLIATE
SRI LANKA INSTITUTE OF ADVANCED TECHNOLOGICAL EDUCATION
(Established in the Ministry of Higher Education, vide in Act No. 29 of 1995)
1)
i. What does WWW stand for? Define it. (02 marks)
ANSWER
World Wide Web (01 Mark)
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.
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.
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
(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>
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
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.
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.
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”.
ANSWER
<html>
<head>
<script>
function validateForm() {
var x =myForm.fname.value;
if (x<1 || x>100) {
alert("invalied number ");}
else
{
alert("invalied number ");
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){
?>
e. Write a proper PHP statement to generate the decision of wrist watch for a given price.
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
License is not specific to a product or restrict other software and also technology
neutral.
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>:  <input type="text" name="stuRegNo" ></td>
</tr>
<tr>
<td>Student Name </td>
<td>:  <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>      DBMS </td>
<td>:& <input type="text" name="dbms" </td>
</tr>
<tr>
<td> Web Development </td>
<td>:  <input type="text" name="webDev" </td>
</tr>
<tr>
<td>      Computer Hardware </td>
<td>:  <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;
(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.
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”];
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))
{
(Total 20 marks)
17
HNDIT 2 Web Application Development- 2017 -2nd semester