Lab 2 Self-Assessment

Lab 2 Self-Assessment Quiz



Question 1 (1 point)

 

Which of the following statements is FALSE about HTTP GET? (There are more than 1 answers)

Question 1 options:


Answer  (1)  It can be used to send confidential data
         (2)  There is no limit to the amount of data you can send from a form with the GET method



Question 2 (1 point)

 

Which statements below is TRUE regarding PHP?

Question 2 options:


Answer : PHP codes are executed on the server-side

Question 3 (1 point)

 

Which one of the following PHP scripts will print out "Temasek Polytechnic" with the enclosed double quotation marks?

Question 3 options:


Answer : <?php

$heading="\"Temasek Polytechnic\"";

Print $heading;

?>




Question 4 (1 point)

 

Which of the following is NOT an advantage of using PHP pages?

Question 4 options:


Answer  :User-friendly graphical interface


Question 5 (1 point)

 
Question 5 options:

Complete each blank with the correct answer (answers are case-sensitive):

<?php

 class calGst {

function afterGst($a)

 { 

      $a = $a * 1.07;

      return $a;

  }

}

$foo = __________________;

$msg ="After GST , total is ";

echo $msg;

 

//it should display the GST amount for $100  

echo ____________ (100);  

?>



Answer  : Fill in the blanks

<?php

 class calGst {

function afterGst($a)

 { 

      $a = $a * 1.07;

      return $a;

  }

}

$foo = __________________;

$msg ="After GST , total is ";

echo $msg;

 

//it should display the GST amount for $100  

echo ____________ (100);  

?>






Question 6 (1 point)

 

Given the following HTML codes, what should the PHP codes be to retrieve the value of "username" from the form submission?

<form action="form.php" method="post">

<input type="text" name="username">

<input type="submit" name="submit">

<input type="submit" name="cancel">

</form>

Question 6 options:

Answer  :$_POST["username"]

Question 7 (1 point)

 

What will be printed out from this PHP code:

 

<?php

$string1= "Hello";

$string2="Dear Friend";

$string3="How do you do?";

$string4=$string1 . " " . $string2. " " .' $string3';

Print $string4;

?>

Question 7 options:



Answer  : Hello Dear Friend $string3

Question 8 (1 point)

 

Given the following php codes, which of the following are the correct ways of calling the function foo in PHP? (There are more than 1 answer)

<?php

function foo($arg_1, $arg_2)

 { 

      $arg_2 = $arg_1 * $arg_2;

      return $arg_2;

  }

?>

 

Question 8 options:

Answer  : echo foo (10, 3);

Question 9 (1 point)

 

Which one of the following statements is TRUE about PHP variables?

Question 9 options:


Answer  : PHP variable names are case-sensitive





Question 10 (1 point)

 

When the following PHP code is run, there is an error.  What is causing the error?

<?php

class Calculate {

private $total=0;

 

public function getSum (int $a, int $b) {

$this->total = $a+$b;

}

}

 

$app = new Calculate;

$app->getSum (93,8); //Output 101

echo $app->total;

?>

Question 10 options:


Answer : Did not specify the scope of the variable $total correctly

Comments

Popular posts from this blog

Simple Login Example (PHP Server + Android Client)

Lab 6: Using split