CTE301

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

ROYAL UNIVERSITY OF BHUTAN

COLLEGE OF SCIENCE AND TECHNOLOGY


PHUENTSHOLING: BHUTAN

WINTER SEMESTER EXAMINATION: 2015

Class

BE (IT) Third Year

Module

Web Application Development

Module Code :

CTE301

Max. Marks :

50

Max. Time

3 Hrs

General Instructions:
1.
A non-programmable calculator is allowed.
2.
All the questions are compulsory.
3.
Make suitable assumptions wherever necessary.

1 of 5

Question No.1

[1 X 5 = 5]

Choose the correct answer:


1.1

Which of the following tags is not a valid way to begin and end
a PHP code block?
a) <% %>
b) <? ?>
c) <! !>
d) <?php ?>

1.2

What is the value displayed when the following is executed?


Assume that the code was executed using the following URL:
testscript.php?c=25
<?php

?>

a)
b)
c)
d)
1.3

function process($c, $d = 25)


{
global $e;
$retval = $c + $d - $_GET['c'] - $e;
return $retval;
}
$e = 10;
echo process(5);

25
-5
10
5

How can you write a class so that some of its properties cannot
be accessed from outside its methods?
a) By declaring the class as private
b) By declaring the methods as private
c) It cannot be done
d) By writing a property overloading method

2 of 5

1.4

If you set a cookie with either setcookie(), you can immediately


check to see whether the client accepted it.
a) True, you can check the $_COOKIE superglobal array
to see if it contains the value you set.
b) True, but only if register_globals is enabled.
c) False, you can only use setcookie() if you need to test
for acceptance.
d) False, you must wait until you receive another HTTP
request to determine whether it includes the Cookie
header.

1.5

Which of the following function is used to pick one or more


random values from PHP Array?
a) array_rand()
b) array_random()
c) Random_array()
d) Rand_array()

Question No.2

[2 X 5 = 10]

State whether the following statements are TRUE or FALSE.


Rewrite the sentences.
2.1

You are not required to initialize a variable when you first


declare it.

2.2

HTTP was originally designed to store data about individual


visits to a Web site.

2.3

Unlike the setcookie() function, you can call the


session_start() function from any location on a Web page.

2.4

MySQL support is not enabled in PHP by default.

2.5

Syntax errors, or parse errors, occur when desired output is not


displayed.
3 of 5

Question No.3

[2 X 10 = 20]

Answer the following questions:


3.1

Explain each of the following string functions. Illustrate your


answer with an example.
(i) substr()
(ii) strcmp()

3.2

What is the difference between a numeric and an associative


array? How can you determine the number of elements there
are in an array?

3.3

Give TWO reasons why using the POST form method is


usually better than GET.

3.4

What are the reasons (ANY TWO reasons) for not able to
connect to a database?

3.5

Identify the two types of comments available in PHP and


indicate when each would be used.

3.6

Give the two PHP variables used to retrieve information from


Web Forms.

3.7

Explain the security risks involved with cookies and how


sessions offer a more secure method of maintaining state.

3.8

Distinguish between the include() statement and the


statement.

require()

3.9

What is the difference between accessing a variable by name


and by reference?

3.10

Exceptions are used to change the normal flow of a script if a


specified error occurs. Explain what happens when an
Exception is triggered?
4 of 5

Question No.4

[5, 10]

Answer the following questions:


4.1 Write an HTML document that contains an input text box to
collect a student's name and a group of checkboxes to let the
student select the sports he likes watching from baseball,
basketball, football, and volleyball. If none of the sports above,
none option should be provided.
Note: the form will be submitted to the file sport.php
4.2 Referring to question 4.1 above, write the PHP script, sport.php,
which prints the student's name and a list of sports he likes.
Validate the form where name cannot be an empty string and only
contains letters and whitespaces. Student has to select at least one
option.

5 of 5

You might also like