Q: 1 In ASP, which of the following method is used to end the current user session and destroy the current session object?
Session.Exit
Session.End
Session.Terminate
Session.Abandon
[ Option D ]
In ASP (Active Server Pages), the Session.Abandon method is used to end the current user session and destroy the session object. When this method is called, all session variables are cleared and the session is terminated.
It is commonly used during logout functionality to remove user-specific data from the server.
Q: 2 What will be the output of the following PHP code?
<?php
$x = 5;
$y = 10;
function fun()
{
$y = $GLOBALS[‘x’] + $GLOBALS[‘y’];
}
Fun();
echo $y;
?>
5
10
15
25
[ Option B ]
In this PHP code, the variables $x = 5 and $y = 10 are defined globally. Inside the function fun(), a new local variable $y is created and assigned the value of $GLOBALS['x'] + $GLOBALS['y'], which is 15.
However, since no global $y; keyword is used, this local $y does not affect the global $y. After the function call, the global $y still holds the value 10, so the output is 10.
Q: 3 What will be the output of the following PHP program?
<?php
$fruits = array(“apple”, “orange”, array (“pear”, “mango”), “banana”);
print (count($fruits,1));
?>
6
5
4
3
[ Option A ]
In this PHP program, the array $fruits contains four elements: "apple", "orange", a nested array ["pear", "mango"], and "banana".
By default, the count() function in PHP counts only the top-level elements, which would give 4. However, since the program uses count($fruits, 1), the second parameter enables recursive counting, meaning elements inside nested arrays are also included in the count.
The nested array ["pear", "mango"] has 2 elements, so the total becomes 4 + 2 = 6. Therefore, the output of the program is 6.
Q: 4 The prefix is used to denote a variable in PHP is?
$
@
~
#
[ Option A ]
In PHP, every variable must start with the dollar sign ($). It is a mandatory prefix used to identify variables in PHP scripts.
<?php
$name="Suresh";
$age=28;
echo $name;
echo $age;
?>
Thank you so much for taking the time to read my Computer Science MCQs section carefully. Your support and interest mean a lot, and I truly appreciate you being part of this journey. Stay connected for more insights and updates! If you'd like to explore more tutorials and insights, check out my YouTube channel.
Don’t forget to subscribe and stay connected for future updates.