Novartis Previous Years Solved Sample Placement Papers
-
Which of the following are correct ways of creating an array?
(i) state[0] = “karnataka”;
(ii) $state[] = array(“karnataka”);
(iii) $state[0] = “karnataka”;
(iv) $state = array(“karnataka”);
A. (iii) and (iv)
B. (ii) and (iii)
C. Only (i)
D. (ii), (iii) and (iv) Answer: Option A
- Solution: Correct ways of creating arrays are $state[0] = “karnataka” and $state = array(“karnataka”).
-
What will be the output of the following PHP code?
<?php
$fruits = array("mango", "apple", "pear", "peach");
$fruits = array_flip($fruits);
echo ($fruits[0]);
?>
A. mango
B. Error
C. peach
D. 0 Answer: Option B
- Solution: The array_flip() function swaps keys with their associated values, and since "0" is not a valid key after flipping, it causes an error.
-
What will be the output of the following PHP code?
<?php
$states = array("karnataka" => array("population" => "11,35,000", "captial" => "Bangalore"),
"Tamil Nadu" => array("population" => "17,90,000", "captial" => "Chennai"));
echo $states["karnataka"]["population"];
?>
A. karnataka 11,35,000
B. 11,35,000
C. population 11,35,000
D. karnataka population Answer: Option B
- Solution: The value of "population" under the "karnataka" key is directly accessed and printed.
-
Which function can be used to move the pointer to the previous array position?
A. last()
B. before()
C. prev()
D. previous() Answer: Option C
- Solution: The prev() function moves the array pointer to the previous position.
-
PHP is _____________ scripting Language?
A. Server side
B. Client side
C. Middle side
D. None of above Answer: Option A
- Solution: PHP is a server-side scripting language, executed on the server.
-
PHP script is executed on?
A. ISP Computer
B. Server computer
C. Client computer
D. None of above Answer: Option B
- Solution: PHP scripts are executed on the server where the code resides.
-
Which of the following variables is not a predefined variable?
A. $get
B. $ask
C. $request
D. $post Answer: Option B
- Solution: $ask is not a predefined PHP variable, unlike $get, $request, and $post.
-
When you need to obtain the ASCII value of a character, which of the following function do you apply in PHP?
A. chr()
B. asc()
C. ord()
D. val() Answer: Option C
- Solution: The ord() function returns the ASCII value of the first character of a string.
-
Which of the following method sends input to a script via a URL?
A. Get
B. Post
C. Both
D. None Answer: Option A
- Solution: The GET method appends the data to the URL.
-
Which of the following function returns a text in title case from a variable?
A. ucwords($var)
B. upper($var)
C. toupper($var)
D. ucword($var) Answer: Option A
- Solution: The ucwords() function capitalizes the first letter of each word in a string.
-
Which of the following function returns the number of characters in a string variable?
A. count($variable)
B. len($variable)
C. strcount($variable)
D. strlen($variable) Answer: Option D
- Solution: The strlen() function returns the length of a string.
-
Which of the following are not considered as Boolean false?
a. FALSE
b. 0
c. “0”
d. “FALSE”
e. 1
f. NULL Answer: d and e
- Solution: "FALSE" and 1 are not considered Boolean false.
-
Which of the following multithreaded servers allow PHP as a plug-in?
a. Netscape FastTrack
b. Microsoft’s Internet Information Server
c. O’Reilly’s WebSite Pro
d. All of the above Answer: Option D
- Solution: All the listed servers allow PHP as a plug-in.