0% found this document useful (0 votes)
21 views9 pages

IT3505 2018 Part1

Uploaded by

s22000634
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)
21 views9 pages

IT3505 2018 Part1

Uploaded by

s22000634
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/ 9

UNIVERSITY OF COLOMBO, SRI LANKA

UNIVERSITY OF COLOMBO SCHOOL OF COMPUTING

DEGREE OF BACHELOR OF INFORMATION TECHNOLOGY ( EXTERNAL)


Academic Year 2018 – 2nd Year Examination – Semester 3

IT3505 – Web Application Development II


PART 1 - Multiple Choice Question Paper

13th May, 2018


(ONE HOUR)

Important Instructions :

 The duration of the paper is 1 (one) hour.


 The medium of instruction and questions is English.
 The paper has 20 questions and 9 pages.
 All questions are of the MCQ (Multiple Choice Questions) type.
 All questions should be answered.
 Each question will have 5 (five) choices with one or more correct
answers.
 All questions will carry equal marks.
 There will be a penalty for incorrect responses to discourage guessing.
 The mark given for a question will vary from 0 (All the incorrect choices
are marked & no correct choices are marked) to +1 (All the correct
choices are marked & no incorrect choices are marked).
 Answers should be marked on the special answer sheet provided.
 Note that questions appear on both sides of the paper.
If a page is not printed, please inform the supervisor immediately.
 Mark the correct choices on the question paper first and then transfer
them to the given answer sheet which will be machine marked. Please
completely read and follow the instructions given on the other
side of the answer sheet before you shade your correct choices.
 Calculators are not allowed.

All Rights Reserved

1
1) Which of the following statements about the PHP programming language is/are correct?
(a) PHP stands for “Hypermedia Preprocessor”.
(b) A PHP script should be surrounded by delimiters <?php> ....<?>
(c) All variable in a PHP script start with the symbol $.
(d) A PHP script can be included anywhere in a HTML script.
(e) A PHP script can be created by using any text editor.

2) Which of the following statements about jQuery is/are correct?


(a) JQuery code is executed by the web server.
(b) JQuery code is executed by the web browser.
(c) JQuery code is executed by both the web browser and the web server.
(d) jQuery is a JavaScript library.
(e) jQuery code can be embeded in an HTML script by using the tags <jquery> and
</jquery>

3) Which of the following is/are (a) web application framework(s)?

i) Django
ii) CodeIgniter
iii) JavaScript

(a) i) only (b) ii) only


(c) iii) only (d) i) and ii) only
(e) ii) and iii) only

4) Consider the following statements about web frameworks.

i) There are no differences between web frameworks and software libraries.


ii) Web frameworks typically provide default behaviors.
iii) A web framework can be used to build different web applications.

Which of the above statements is/are correct?


(a) i) only (b) ii) only
(c) iii) only (d) i) and ii) only
(e) ii) and iii) only

2
5) Consider the following statements.
i) When the GET method is used to submit data of a web Form to the server,
variables are displayed in the URL.
ii) The PHP statement fopen(“mydata.txt”,”r”); opens a file named
“mydata.txt” to which data can be written.
iii) The location of a script can be obtained from the PHP superglobal variable $_GET.

Which of the above statements is/are correct?


(a) i) only (b) ii) only
(c) iii) only (d) i) and iii) only
(e) ii) and iv) only

6) What would be the output of the following script when executed?

<?php
echo 2 + "1","2"+1;
?>

(a) 321 (b) 33 (c) 213


(d) 2121 (e) 21

7) What would be the output of the following script when executed?


<?php
echo 3+ 2**3*2 - 4/2 - 4;
?>

(a) 244 (b) 61 (c) 21


(d) 123 (e) 13

8) What would be the output of the following script when executed?


<?php
$a = "1,2,3,4,5,6";
$b = explode(",",$a);
echo count($b),",",$b[1];
?>

(a) 6,1 (b) 6,2 (c) 21,1


(d) 21,2 (e) 11,2

3
9) Which of the following PHP script(s) display the value 12 when executed?

(a) (b)
<?php <?php
$a = array(1,2,3,4,5,6); $a = array(1,2,3,4,5,6);
$sum = 0;$i = 0; $sum = 0;
while ($i < count($a)){ foreach ($a as $key=>$val){
if ($i % 2){ if ($val % 2){
$sum = $sum + $i; $sum = $sum + $key;
} }
$i++;
} }
echo $sum; echo $sum;
?> ?>

(c) (d)
<?php
$a = array(1,2,3,4,5,6); <?php
$sum = 0;$i = 0; $a = array(1,2,3,4,5,6);
while ($i < count($a)){ $sum = 0;
if ($i % 2){ foreach ($a as $key=>$val){
$sum = $sum +$a[$i]; if ($key % 2){
} $sum = $sum + $val;
$i++; }
}
echo $sum; }
?> echo $sum;
?>
(e)
<?php
$a = array(1,2,3,4,5,6);
$sum = array_sum($a);
echo $sum;
?>

10) Which of the following PHP scripts is/are syntactically valid?

(a) (b) (c)


<?php <php <?php
$a = 4; echo $a; $a = $b = 4; $a = 4;
?> echo $a,$b; if ($a == 4){
?> echo $a;
}
?
(d) (e)
<?php <?php
$a = 4; $a = 2;
if ($a){ while $a==4 {
echo $a; $a--;
} }
?> ?>

4
11) Which one of the following statements about PHP user defined functions is/are correct?

(a) Each user defined function declaration should start with the reserved word def.
(b) Function names are case-sensitive.
(c) Function can have zero or more parameters.
(d) A function may not return any value.
(e) A function declaration may have other function declarations inside its body.

12) Consider the following PHP function declaration.

function f1($a = 20,$b=30){


if ($a > $b){
return $a;
} else {
return $b;
}
}
Now, consider the following statements about the function invocation.
i) When the function is called as f1(2,5) the return value would be 5.
ii) When the function is called as f1(2) the return value would be 30.
iii) When the function is called as f1() the return value would be 20.

Which of the above statements is/are correct?


(a) i) only (b) ii) only
(c) iii) only (d) i) and ii) only
(e) ii) and iii) only

5
13) Consider the following PHP function declaration.

function f1($a){
if (count($a) == 0){
return 0;
} else {
return array_shift($a)+f1($a);
}
}

Note : The array_shift() function removes the first element (the element at index 0) from an
array, and returns the value of the removed element.

What would be the return value when this function is called as f1(array(1,2,3,4,5,6))?
(a) 1 (b) 6 (c) 7
(d) 4 (e) 21

14) What would be the output of the following script when executed?

<?php
$a = 10;
$b = 15;

function f1(&$a,$b){
$a = 20;
$b = 30;
}

f1($a,$b);
echo $a,",",$b;
?>

(a) 10,15 (b) 20,30 (c) 10,30


(d) 20,15 (e) 10,20

6
Questions (15), (16) and (17) are based on the code given below.
<?php
class Rectangle{
private $length,$width;

function __construct($length,$width){
$this->length = $length;
$this->width = $width;
}

function setLength($length){
$this->length = $length;
}

function setWidth($width){
$this->width = $width;
}

function area(){
return $this->length * $this->width;
}

function perimeter(){
return ($this->length + $this->width) * 2;
}
}
?>

15) Which of the following statements about the above definition is/are correct?
(a) Both setWidth($width)and area() are methods of the class.
(b) The function area() can be accessed only by the statements inside the class
declaration.
(c) The function setLength($length) is a public method of this class.
(d) The Rectangle class has a constructor.
(e) The __construct($length,$width)method is executed automatically
whenever new instances of this class are created.

16) Which of the following statement(s) would not result in an error when executed?
(a) $c = new Rectangle();
(b) $c = new Rectangle(5);
(c) $c = new Rectangle(5,10);
(d) $c = new Rectangle(5,5,10);
(e) new Square(5,10);
7
17) What would be displayed if the following statements are executed in the given order?
$s = new Rectangle (2,3);
echo $s->area($s->setLength(10)),",",$s->perimeter();

(a) 6,10 (b) 10,5 (c) 30,10


(d) 10,30 (e) 30,26

Questions (18), (19) and (20) are based on the HTML script given below.
<!DOCTYPE html>
<html lang="en">
<head>
<title>JQuery Examples</title>
<script src="https://code.jquery.com/jquery-
3.2.1.slim.min.js"></script>
<script type="text/javascript">

$( document ).ready(function() {
var colour_n = "Red";

$("p.c1").click(function(){
$(this).hide();
});
$("p.c2").click(function(){
var colour_t = $(".c2").css("color");
$(this).css("color", colour_n);
colour_n = colour_t;

});
});

function display(){
$( ".c1" ).show();
}

</script>
</head>
<body>
<button type="button" onclick="display()">Display</button>
<p class="c1"> <b> First Paragraph </b> </p>
<p class="c2" style="color:Blue;"> <b> Second Paragraph </b>
</p>
</body>
</html>

8
18) Which of the following statements is/are correct when the HTML script is rendered by a web
browser?
(a) There would be a button on the rendered page.
(b) When rendered, it loads the jQuery library from the folder where the HTML
script is stored.
(c) There would be a paragraph with the text “First Paragraph” on the page.
(d) The text “First Paragraph” on the page would appear in red colour.
(e) There would be a paragraph with the text “This is a Paragraph” on the page.

19) Consider the following statements.

i) The construct $("p.c1") would return a DOM object.


ii) The execution of the statement $( ".c1" ).show(); would result in showing all
paragraphs of the document.
iii) The execution of the statement $(".c2").css("color"); would results in retrieving the
value of the property color of the first DOM elements with the class name c2.

Which of the above statements is/are correct?


(a) i) only (b) ii) only
(c) iii) only (d) i) and iii) only
(e) ii) and iii) only

20) Consider the following actions and reactions.


i) When the mouse is clicked on the text “First Paragraph” that text would disappear
from the page.
ii) When the mouse is clicked on the text “Second Paragraph” the colour of that text
would change to red.
iii) When the mouse is clicked on the text “Second Paragraph” when the colour of that
text is blue its colour would change to red.

Which of the above statements is/are correct?


(a) i) only (b) ii) only
(c) iii) only (d) i) and iii) only
(e) ii) and iii) only

************************

You might also like