Week two php
Which one of the following is the right way to invoke a method? Select one: a. $object -> methodNAme(); b. object -> methodName(); c. object :: methodName(); d. $object::methodName();
a. $object -> methodNAme();
What will be the output of the following code?<?php$i = 0;while ((--$i > ++$i) - 1){ print $i;}?> Select one: a. 00000000000000.....infinitely b. -1-1-1-1-1-1-1-1 .......infinitely c. No output d. Error
a. 00000000000000.....infinitely
$var1 = 10; $var2 = var1; What value is present in $var2? Select one: a. 10 b. Something Else
a. 10
What will be the output of the following code<?php $x = 75;$y = 25; function addition(){$GLOBALS['z'] = $GLOBALS['x'] + $GLOBALS['y'];}addition();echo $z;?> Select one: a. 100 b. Error c. 75 d. 25
a. 100
What will be the output of the following code?<?php$i = 0;while(++$i || --$i){ print $i;}?> Select one: a. 1234567891011121314.....infinitely b. 01234567891011121314......infinitely c. 1 d. 0
a. 1234567891011121314.....infinitely
What will be the output of the following PHP code?<?php$i = 5;while (--$i > 0 || ++$i){ print $i;}?> Select one: a. 4321111111......infinitely b. 55555555.....infinitely c. 54321 d. 5
a. 4321111111......infinitely
Which of these definitions best explain the term class? Select one: a. A collection of variables and functions working with these variables b. Sets and gets the class own properties and methods. c. Is the embodiment of the real life objects
a. A collection of variables and functions working with these variables
Which operators have a higher precedence? Select one: a. Arithmetic operator b. Comparison operator c. Logical operators d. Boolean operator
a. Arithmetic operator
How can you check that the value of a given variable is a number? Select one: a. By using is_numeric() function b. Something Else
a. By using is_numeric() function
_____________ are particularly useful when working with the values that definitely will not require modifications. Select one: a. Constants b. Variables c. Expressions d. Keywords
a. Constants
Which of the following property scope is not supported by PHP? Select one: a. Friendly b. Final c. Public d. Static
a. Friendly
Which statement is correct for using Get method? Select one: a. It has limited length b. It has a greater capacity c. It may encounter some error d. None
a. It has limited length
How can PHP and HTML interact? Select one: a. It is possible to generate HTML through PHP scripts, and it is possible to pass the information from HTML to PHP. b. Something Else
a. It is possible to generate HTML through PHP scripts, and it is possible to pass the information from HTML to PHP.
The Logical operator || stands for? Select one: a. OR b. AND c. NOT
a. OR
What will be the output of the following code?<?php$colors = array("red","green","blue","yellow"); foreach ($colors as $value){echo "$value <br>";}?> Select one: a. Red Green Blue Yellow b. Red c. No Output d. Error
a. Red Green Blue Yellow
What is the difference between the require() and reqire_once()? Select one: a. Require() and require_once() perform the same task except that the require_once() function checks if the PHP script is already included or not before executing it. b. Something Else
a. Require() and require_once() perform the same task except that the require_once() function checks if the PHP script is already included or not before executing it.
A mutator methods are also called as... Select one: a. Setter b. Accessor c. Getter d. Destructor
a. Setter
A for loop will check the condition statement before executing the segment of code between curly braces? Select one: a. True b. False
a. True
A foreach loop contains an internal Pointer that points to an index ( or elements) in an array and assigns the value of that element to a variable? Select one: a. True b. False
a. True
After require_once() is encountered, any subsequent attempts to include the same file will be ignored. Select one: a. True b. False
a. True
Following Condition will return you TRUE or FALSE? (4 >=4 || 8<1) Select one: a. True b. False
a. True
For each loop can only be used for arrays? Select one: a. True b. False
a. True
If a file has already been included, include_once() will not execute. Select one: a. True b. False
a. True
Most of the syntax for the PHP is borrowed from a perl, java and c? Select one: a. True b. False
a. True
PHP can run on the different environments (Ex. Windows, Linux and unix)? Select one: a. True b. False
a. True
PHP files are returned to the browser as a plain PHP? Select one: a. True b. False
a. True
The die() and exit() functions do almost the exact same thing. Select one: a. True b. False
a. True
The following condition will return TRUE or FALSE? ((4 >=4 && 8 <1) || (44 ==33 || 5 > 3)) Select one: a. True b. False
a. True
The if statement is used to execute some code only if a specific condition is true. Select one: a. True b. False
a. True
What will be the output of eth following code?<?phpfunction movie($int){$movies = array("Fight Club", "Kill Bill", "Pulp Fiction");echo "You Do Not Talk About ". $movie[$integer];}movie(0);?> Select one: a. You Do NOT Talk About Fight Club b. You Do NOT Talk About Kill Bill c. You Do NOT Talk About Pulp Fiction d. None of the mentioned
a. You Do NOT Talk About Fight Club
How can you check if a given variable is empty? Select one: a. empty() function b. Something Else
a. empty() function
How is it possible to return a value from a function? Select one: a. return $value; b. Something Else
a. return $value;
Which Logical operator has higher precedence from following? Select one: a. && b. ! c. || d. Xor
b. !
Which superglobal variables holds information about headers, paths, and script locations? Select one: a. $_GET b. $_SERVER c. $_GLOBALS d. $_SESSION
b. $_SERVER
There are two objects- $product1 = new Shop(); $product2 = new Shop(); Which of the following statement is right about them? Select one: a. $product1 and $product2 are same objects of the same type generated from a single class. b. $product1 and $product2 are different objects of the same type generated from a single class. c. $product1 and $product2 are same objects of the different type generated from a single class. d. $product1 and $product2 are different objects of the different type generated from a single class.
b. $product1 and $product2 are different objects of the same type generated from a single class.
Decrement operator is denoted by. Select one: a. ++ b. - - c. % % d. //
b. - -
What will be the output of the following PHP code?<?php$i = 5;while (--$i > 0 && ++$i){ print $i;}?> Select one: a. 5 b. 55555555555.....infinitely c. 54321 d. Error
b. 55555555555.....infinitely
Which of these definitions best explain the term property? Select one: a. Groups the code that is related to one topic b. A variable within a class c. A function within a class
b. A variable within a class
The Logical Operator && stands for? Select one: a. OR b. AND c. NOT
b. AND
Loops that iterate for the fixed number of times are called Select one: a. Unbounded Loop b. Bounded Loop c. While Loop d. For loop
b. Bounded Loop
What will be displayed in the browser when the following PHP code is excuted?<?php for ($counter = 20; $counter < 10; $counter++){ echo "Hello Robert "; } echo "Counter is: $counter";?> Select one: a. Hello Robert b. Counter is: 20 c. Hello Robert Counter is: 22 d. Hello Robert Hello Robert counter is: 22
b. Counter is: 20
All the large websites take longer to create with PHP? Select one: a. True b. False
b. False
An identifier name can be identical to any PHP predefined keywords. Select one: a. True b. False
b. False
In PHP Objects are passed by reference? Select one: a. True b. False
b. False
Include files in PHP scripts must have the file extension ".inc" Select one: a. True b. False
b. False
PHP does not support databases? Select one: a. True b. False
b. False
PHP is the closed source software? Select one: a. True b. False
b. False
The Following Condition will return you TRUE or FALSE? (4 >=4 && 8<1) Select one: a. True b. False
b. False
When using the POST method, variables are displayed in the URL: Select one: a. True b. False
b. False
Which keyword precedes a method name? Select one: a. Method b. Function c. Public d. Protected
b. Function
Which method passes arguments from one page to next as a part of uniform resource indicator? Select one: a. Post method b. Get method c. Parsing method d. None of them
b. Get method
Which version of PHP introduced the visibility keywords i.e public, private and protected? Select one: a. PHP 4 b. PHP 5 c. PHP 5.1 d. PHP 5.3
b. PHP 5
Which of the following terms originates from the Greek language that means "having multiple forms"? Define OOP's ability to redefine, a class's characterstics? Select one: a. Abstraction b. Polymorphism c. Inheritance d. Differential
b. Polymorphism
Which of the following method is suitable when you need to send a larger form submission? Select one: a. Get b. Post c. Both Get and Post d. There is no direct way for larger form. You need to store them in a file and retrieve
b. Post
The PHP operators Boolean AND and Boolean OR [ && || ] has a ___________ associativity. Select one: a. Left b. Right c. Both d. NA
b. Right
$GLOBALS, $_SERVER, $REQUEST, $_POST, $_GET, $_FILES, $_COOKIE, $_SESSION all are the examples of Select one: a. Super array b. Superglobals c. Local variables d. None of them
b. Superglobals
Which one is the right way to call a class constant, given that the class is mathFunction? Select one: a. Echo PI; b. echo mathFunction :: PI; c. echo mathFunction -> PI; d. echo mathFunction=PI;
b. echo mathFunction :: PI;
In the PHP code given below, what is/are the properties?< ?php class Example {public $name;function Sample(){echo "This is an example";}} ?> Select one: a. echo "This is an example"; b. pubic $name; c. class Example d. function sample()
b. pubic $name;
PHP stores all the global variables in an array called Select one: a. $GLOBAL_ARRAY[ ] b. $G_ARRAY[ ] c. $GLOBALS[ ] d. $GLOB_ARRAY[ ]
c. $GLOBALS[ ]
How do you get information from a form that is submitted using the "get" method? Select one: a. Request.QueryString; b. Request.Form; c. $_GET [ ];
c. $_GET [ ];
Which of the following can be used to instantiate an object in PHP assuming class name to be Foo? Select one: a. $obj = new $foo; b. $obj = new foo; c. $obj = new foo(); d. obj = new foo();
c. $obj = new foo();
Which characters are used to access property variables on an object-by-object basis? Select one: a. :: b. = c. -> d. .
c. ->
What will be displayed in the browser when the following PHP code is executed?<?php $numbers = array(9, 2, 1); foreach ($numbers as $value){ echo "$value "; } ?> Select one: a. 9 1 2 b. 9 2 c. 9 2 1 d. 1
c. 9 2 1
Which method is not suitable for logins because it stores data in the client browser memory? Select one: a. Post method b. Put method c. Get method d. Set method
c. Get method
An object is a/an ________of a class. Select one: a. Type b. Prototype c. Instances d. Objects
c. Instances
The Logical operator! Stands for? Select one: a. OR b. AND c. NOT
c. NOT
What will be the output of the following PHP code?<?php$i = 0;while (++$i && --$i){ print $i;}?> Select one: a. 1234567891011121314......infinitely b. 012345678910111213......infinitely c. No output d. Error
c. No output
Which version of the PHP introduced the instanceof keyword? Select one: a. PHP 4 b. PHP 5.3 c. PHP 5 d. PHP 6
c. PHP 5
For accessing the global variables anywhere in the script, PHP uses. Select one: a. Get and Post Methods b. Functions c. Superglobal arrays d. None of them
c. Superglobal arrays
The preferred way to traverse a two-dimensional array is to use. Select one: a. A do while statement b. A for statement c. Two nested for statements d. Three nested for statements
c. Two nested for statements
Which keyword is used to declare a class? Select one: a. public b. function c. class d. this
c. class
Which keyword allows the class member (methods and properties) to be used without needing to instantiate a new instance of the class? Select one: a. protected b. final c. static d. private
c. static
Which keyword is used to refer to the properties or methods within the class itself? Select one: a. private b. public c. protected d. $this
d. $this
Which of the following is not a valid class name? Select one: a. ShopProduct b. Shopproduct c. Shopproduct1 d. 1shopproduct
d. 1shopproduct
The practice of separating the user from the true inner workings of an application through the well known interfaces is known as.. Select one: a. Polymorphism b. Inheritance c. Encapsulation d. Abstraction
d. Abstraction
The practice of creating objects based on predefined classes is often referred to as .. Select one: a. Class creation b. Object creation c. Object instantiation d. Class instantiation
d. Class instantiation
PHP recognizes constructors by the name. Select one: a. Classname() b. _construct() c. Function _construct() d. Function __construct() ----→ double underscore
d. Function __construct() ----→ double underscore
What will be the output of the following code?<?php$i = 2;while (++$i){ while (--$i > 0)print $i;}?> Select one: a. 210 b. 10 c. No output d. Infinite loop
d. Infinite loop
What will be displayed in the browser when the following PHP code is executed:<?php for ($counter = 10; $counter < 10; $counter = $counter + 5){echo "Hello"; } ?> Select one: a. Hello Hello Hello Hello Hello b. Hello Hello Hello c. Hello d. None of the above
d. None of the above
If we omit the visibility keyword in our method declaration, by default the method will be declared as: Select one: a. Private b. Protected c. Friendly d. Public
d. Public
What will be the output of the following code?<?php$a = array("hi", "hello", "bye");foreach ($a as $value) {if (count($a) == 2) print $value; }?> Select one: a. hihellobye b. infinite loop c. hihello d. no output
d. no output