Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages
Filter by Categories
nmims post
Objective Type Set
Online MCQ Assignment
Question Solution
Solved Question
Uncategorized

Interview MCQ Set 1

1. What will be the output of the following PHP code?

  1. <?php
  2.     $title = "O'malley wins the heavyweight championship!";
  3.     echo ucwords($title);
  4. ?>

a) O’Malley Wins The Heavyweight Championship!
b) O’malley Wins The Heavyweight Championship!
c) O’Malley wins the heavyweight championship!
d) o’malley wins the heavyweight championship!

View Answer

Answer: d [Reason:] The ucwords() function capitalizes the first letter of each word in a string. Its prototype follows: string ucwords(string str).

2. What will be the output of the following PHP code?

  1. <?php
  2.     echo str_pad("Salad", 5)." is good.";
  3. ?>

a) SaladSaladSaladSaladSalad is good
b) is good SaladSaladSaladSaladSalad
c) is good Salad
d) Salad is good

View Answer

Answer: d [Reason:] The str_pad() function pads a string with a specified number of characters.

3. What will be the output of the following PHP code?

  1. <?php
  2.     $str = "Hello World"
  3.     echo wordwrap($str,5,"<br>n");    
  4. ?>

a) Hello World
b) Hello
World
c) Hell
o wo
rld
d) World

View Answer

Answer: b [Reason:] The wordwrap() function wraps a string into new lines when it reaches a specific length.

4. What will be the output of the following PHP code?

  1. <?php
  2.     echo ucwords("i love my country");
  3. ?>

a) I love my country
b) i love my Country
c) I love my Country
d) I Love My Country

View Answer

Answer: d [Reason:] The ucwords() function converts the first character of each word in a string to uppercase.

5. What will be the output of the following PHP code?

  1. <?php
  2.     echo lcfirst("welcome to India");
  3. ?>

a) welcome to India
b) welcome to india
c) Welcome to India
d) Welcome to india

View Answer

Answer: a [Reason:] The lcfirst() function converts the first character of a string to lowercase.

6. What will be the output of the following PHP code?

  1. <?php
  2.     echo hex2bin("48656c6c6f20576f726c6421");
  3. ?>

a) Hello World!
b) welcome to india
c) This is PHP!
d) MCQ questons

View Answer

Answer: a [Reason:] The hex2bin() function converts a string of hexadecimal values to ASCII characters.

7. What will be the output of the following PHP code?

  1. <?php 
  2.     $str = addslashes('What does "yolo" mean?');
  3.     echo($str); 
  4. ?>

a) What does /”yolo/” mean?
b) What does ”yolo” mean?
c) What does ”yolo” mean?
d) What does ”yolo” mean?

View Answer

Answer: c [Reason:] The addslashes() function returns a string with backslashes in front of predefined characters.

8. What will be the output of the following PHP code?

  1. <?php
  2.     $str = "Hello world. It's a beautiful day.";
  3.     print_r (explode(" ",$str));
  4. ?>

a) Array ( [0] => Hello [0] => world. [0] => It’s [0] => a [0] => beautiful [0] => day. )
b) Array ( [0] => Hello [1] => world. [2] => It’s [3] => a [4] => beautiful [5] => day. )
c) Hello world. It’s a beautiful day
d) Array ( [1] => Hello [2] => world. [3] => It’s [4] => a [5] => beautiful [6] => day. )

View Answer

Answer: b [Reason:] The explode() function breaks a string into an array.

9. What will be the output of the following PHP code?

  1. <?php
  2.     echo strtr("Hilla Warld","ia","eo");
  3. ?>

a) Hilla Warld
b) Hello World
c) ia
d) eo

View Answer

Answer: b [Reason:] The strtr() function translates certain characters in a string.

10. What will be the output of the following PHP code?

  1. <?php
  2.     echo stripos("I love php, I love php too!","PHP");
  3. ?>

a) 3
b) 7
c) 8
d) 10

View Answer

Answer: b [Reason:] The stripos() function finds the position of the first occurrence of a string inside another string.

Interview MCQ Set 2

1. What will be the output of the following PHP code ?

  1. <?php
  2. $a = "$winner";
  3. $b = "/$looser";
  4. echo $a,$b;
  5. ?>

a) $winner/$looser
b) /$looser
c) /
d) $looser

View Answer

Answer: c [Reason:] Since variables $winner and $looser is not defined we only see / as output.

2. What will be the output of the following PHP code ?

  1. <?php
  2. $a = "$winner";
  3. $b = "$looser";
  4. echo $a, $b;
  5. ?>

a) $winner$looser
b) $looser
c)
d) $looser

View Answer

Answer: d [Reason:] As there is a backslash before $ it takes it as a string and not a variable therefore we get $looser as the output.

3. What will be the output of the following PHP code ?

  1. <?php
  2. $a = "$winner";
  3. $b = "$looser";
  4. echo $a, $b;
  5. ?>

a) $winner$looser
b) $looser
c)
d) $looser

View Answer

Answer: c [Reason:] Since two backslashes are used together, a single backslash is printed on the screen and as $looser is not initialised only single backslash is printed.

4. What will be the output of the following PHP code ?

  1. <?php
  2. $x = 5;
  3. $y = 10;
  4. function fun()
  5. {
  6.     $GLOBALS['y'] = $GLOBALS['x'] + $GLOBALS['y'];
  7. } 
  8. fun();
  9. echo $y;
  10. ?>

a) 5
b) 10
c) 15
d) Error

View Answer

Answer: c [Reason:] You can access the global variable using $GLOBALS[‘globalvariablename’].

5. What will be the output of the following PHP code ?

  1. <?php
  2. $x = 5;
  3. $y = 10;
  4. function fun()
  5. {
  6.     $y = $GLOBALS['x'] + $GLOBALS['y'];
  7. } 
  8. fun();
  9. echo $y;
  10. ?>

a) 5
b) 10
c) 15
d) Error

View Answer

Answer: b [Reason:] The value of global variable y does not change therefore it’ll print 10;

6. What will be the output of the following PHP code ?

  1. <?php
  2. function fun()
  3. {
  4.     $x = 0;
  5.     echo $x;
  6.     $x++;
  7. }
  8. fun();
  9. fun();
  10. fun();
  11. ?>

a) 012
b) 123
c) 000
d) 111

View Answer

Answer: c [Reason:] Every time the function is called the value of x becomes 0, therefore we get 0 on every function call.

7. What will be the output of the following PHP code ?

  1. <?php
  2. function fun()
  3. {
  4.     static $x = 0;
  5.     echo $x;
  6.     $x++;
  7. }
  8. fun();
  9. fun();
  10. fun();
  11. ?>

a) 012
b) 123
c) 111
d) Error

View Answer

Answer: a [Reason:] When static is used, each time the function is called, that variable will still have the information it contained from the last time the function was called.

8. What will be the output of the following PHP code ?

  1. <?php
  2. static $x = 0;
  3. function fun()
  4. {
  5.     echo $x;
  6.     $x++;
  7. }
  8. fun();
  9. fun();
  10. fun();
  11. ?>

a) 012
b) 123
c) Nothing
d) Error

View Answer

Answer: c [Reason:] Since variable x is not defined inside the function fun(), nothing will be printed.

9. What will be the output of the following PHP code ?

  1. <?php
  2. $x=0;
  3. function fun()
  4. {
  5.     echo $GLOBALS['x'];
  6.     $GLOBALS['x']++;
  7. }
  8. fun();
  9. fun();
  10. fun();
  11. ?>

a) 000
b) 012
c) 123
d) Error

View Answer

Answer: b [Reason:] Since, we are using $GLOBALS[‘x’], the question is similar to question 7.

10. What will be the output of the following PHP code ?

  1. <?php
  2. $x = 0;
  3. function fun()
  4. {
  5.     echo $GLOBALS['x'];
  6.     $x++;
  7. }
  8. fun();
  9. fun();
  10. fun();
  11. ?>

a) 000
b) 012
c) Nothing
d) Error

View Answer

Answer: a [Reason:] This question is similar to question 6.

Interview MCQ Set 3

1. What will be the output of the following PHP code ?

  1. <?php
  2. $i = 0; $j = 1; $k = 2;
  3. print !(($i + $k) < ($j - $k));
  4. ?>

a) 1
b) true
c) false
d) 0

View Answer

Answer: a [Reason:] True is 1.

2. What will be the output of the following PHP code ?

  1. <?php
  2. $i = 0;$j = 1;$k = 2;
  3. print !(( +  + $i + $j) > ($j - $k));
  4. ?>

a) 1
b) no output
c) error
d) 0

View Answer

Answer: b [Reason:] The equation outputs false .

3. What will be the output of the following PHP code ?

  1. <?php
  2. $i = 0;$j = 1;$k = 2;
  3. print (( +  + $i + $j) >! ($j - $k));
  4. ?>

a) 1
b) no output
c) error
d) 0

View Answer

Answer: a [Reason:] Negation of a number is 0.

4. What will be the output of the following PHP code ?

  1. <?php
  2. $a = 0x6db7;
  3. print $a<<6;
  4. ?>

a) 1797568
b) no output
c) error
d) 0x6dc0

View Answer

Answer: a [Reason:] The output is in decimal.

5. What will be the output of the following PHP code ?

  1. <?php
  2. $a  =  'a' ;
  3. print $a * 2;
  4. ?>

a) 192
b) 2
c) error
d) 0

View Answer

Answer: d [Reason:] Characters cannot be multiplied.

6. What will be the output of the following PHP code ?

  1. <?php
  2. $a  =  '4' ;
  3. print  +  + $a;
  4. ?>

a) no output
b) error
c) 5
d) 0

View Answer

Answer: c [Reason:] The character is type casted to integer before multiplying.

7. What will be the output of the following PHP code ?

  1. <?php
  2. $a  =  '12345';
  3. print "qwe{$a}rty";
  4. ?>

a) qwe12345rty
b) qwe{$a}rty
c) error
d) no output

View Answer

Answer: a [Reason:] {$}dereferences the variable within.

8. What will be the output of the following PHP code ?

  1. <?php
  2. $a  =  '12345';
  3. print "qwe".$a."rty";
  4. ?>

a) qwe12345rty
b) qwe$arty
c) error
d) no output

View Answer

Answer: a [Reason:] . dereferences the variable/string within.

9. What will be the output of the following PHP code ?

  1. <?php
  2. $a  =  '12345';
  3. echo 'qwe{$a}rty';
  4. ?>

a) qwe12345rty
b) qwe{$a}rty
c) error
d) no output

View Answer

Answer: b [Reason:] qwe{$a}rty, single quotes are not parsed.

10. What will be the output of the following PHP code ?

  1. <?php
  2. $a  =  '12345';
  3. echo "qwe$arty";
  4. ?>

a) qwe12345rty
b) qwe$arty
c) qwe
d) error

View Answer

Answer: c [Reason:] qwe, because $a became $arty, which is undefined.

Interview MCQ Set 4

1. What will be the output of the following PHP code ?

  1. <?php
  2. $age = array("Harry" => "21", "Ron" => "23","Malfoy" => "21");
  3. array_change_key_case($age, CASE_UPPER);
  4. array_pop($age);
  5. print_r($age);
  6. ?>

a) Array ( [Harry] => 21 [Ron] => 23 [Malfoy] => 21 )
b) Array ( [HARRY] => 21 [RON] => 23 [MALFOY] => 21 )
c) Array ( [HARRY] => 21 [RON] => 23 )
d) Array ( [Harry] => 21 [Ron] => 23 )

View Answer

Answer: c [Reason:] The array_change_key_case() function changes all keys in an array to lowercase or uppercase and arry_pop() removes last element

2. What will be the output of the following PHP code ?

  1. <?php
  2. $a1 = array("a" => "red", "b" => "green", "c" => "blue", "d" => "yellow");
  3. $result = array_flip($a1);
  4. print_r($result);
  5. ?>

a) Array ( [red] => red [green] => green [blue] => blue [yellow] => yellow )
b) Array ( [a] => a [b] => b [c] => c [d] => d )
c) Array ( [red] => a [green] => b [blue] => c [yellow] => d )
d) Array ( [a] => red [b] => green [c] => blue [d] => yellow )

View Answer

Answer: c [Reason:] The array_flip() function flips/exchanges all keys with their associated values in an array.

3. What will be the output of the following PHP code ?

  1. <?php
  2. $a1 = array("a" => "red", "b" => "green", "c" => "blue", "d" => "yellow");
  3. $a2 = array("e" => "red","f" => "green", "g" => "blue");
  4. $result = array_intersect($a1, $a2);
  5. print_r($result);
  6. ?>

a) Array ( [a] => red [b] => green [c] => blue )
b) Array ( [a] => red [b] => green [c] => blue [d] => yellow )
c) Array ( [e] => red [f] => green [g] => blue )
d) Array ( [a] => red [b] => green [c] => blue [d] => yellow [e] => red [f] => green [g] => blue )

View Answer

Answer: a [Reason:] The array_intersect() function compares the values of two (or more) arrays, and returns the matches.

4. What will be the output of the following PHP code ?

  1. <?php
  2. $a = array(12, 5, 2);
  3. echo(array_product($a));
  4. ?>

a) 024
b) 120
c) 010
d) 060

View Answer

Answer: b [Reason:] The array_product() function calculates and returns the product of an array.

5. What will be the output of the following PHP code ?

  1. <?php
  2. $a = array("a" => "Jaguar", "b" => "Land Rover", "c" => "Audi", "d" => "Maseratti");
  3. echo array_search("Audi", $a);
  4. ?>

a) a
b) b
c) c
d) d

View Answer

Answer: c [Reason:] The array_search() function searches for the element and returns the key of that element.

6. What will be the output of the following PHP code ?

  1. <?php
  2. $city_west = array("NYC", "London");
  3. $city_east = array("Mumbai", "Beijing");
  4. print_r(array_replace($city_west, $city_east));
  5. ?>

a) Array ( [1] => Mumbai [0] => Beijing )
b) Array ( [0] => NYC [1] => London )
c) Array ( [1] => NYC [0] => London )
d) Array ( [0] => Mumbai [1] => Beijing )

View Answer

Answer: d [Reason:] The array_replace() function replaces the values of the first array with the values from following arrays

7. What will be the output of the following PHP code ?

  1. <?php
  2. $people = array("Peter", "Susan", "Edmund", "Lucy");
  3. echo pos($people);
  4. ?>

a) Lucy
b) Peter
c) Susan
d) Edmund

View Answer

Answer: b [Reason:] The pos() function returns the value of the current element in an array, and since no operation has been done, the current element is the first element.

8. What will be the output of the following PHP code ?

  1. <?php
  2. $number = range(0, 5);
  3. print_r ($number);
  4. ?>

a) Array ( [0] => 0 [1] => 1 [2] => 2 [3] => 3 [4] => 4 [5] => 5 )
b) Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 )
c) Array ( [0] => 5 [1] => 5 [2] => 5 [3] => 5 [4] => 5 [5] => 5 )
d) Array ( [0] => 0 [5] => 5 )

View Answer

Answer: a [Reason:] The range() function creates an array containing a range of elements.

9. What will be the output of the following PHP code ?

  1. <?php
  2. $array = array("red", "green");
  3. array_push($array, "blue", "yellow");
  4. print_r($array);
  5. ?>

a) Array ( [0] => red [1] => green [2] => blue [3] => yellow )
b) Array ( [0] => blue [1] => yellow [2] => red [3] => green )
c) Array ( [0] => red [1] => green )
d) Array ( [0] => blue [1] => yellow )

View Answer

Answer: a [Reason:] The array_push() function inserts one or more elements to the end of an array.

10. What will be the output of the following PHP code ?

  1. <?php
  2. $age = array("Harry" => "21", "Ron" => "19", "Malfoy" => "23");
  3. ksort($age);
  4. foreach($age as $x => $x_value)
  5. {
  6.     echo "Key=" . $x . ", Value=" . $x_value;
  7.     echo "<br>";
  8. }
  9. ?>

a) Key = Harry, Value = 21
Key = Ron, Value = 21
Key = Malfoy, Value = 23
b) Key = Harry, Value = 21
Key = Ron, Value = 19
Key = Malfoy, Value = 23
c) Key = Harry, Value = 21
Key = Malfoy, Value = 23
Key = Ron, Value = 19
d) Key = Ron, Value = 19
Key = Harry, Value = 21
Key = Malfoy, Value = 23

View Answer

Answer: c [Reason:] The ksort() function sorts an associative array in ascending order, according to the key.

Interview MCQ Set 5

1. How many types of protocols are important for instant messaging ?
a) 2
b) 3
c) 4
d) All of the mentioned

View Answer

Answer: b [Reason:] In an effort to create an interoperability standard between different IM clients, several instant messaging protocols have been created.

2. Point out the correct statement:
a) Every third-party IM clients aim to allow their users to connect to the different major IM services
b) SIP stands for Secure Initiation Protocol
c) XMPP stands for Extensible Messaging and Presence Protocol
d) All of the mentioned

View Answer

Answer: c [Reason:] SIP stands for Session Initiation Protocol.

3. Which of the following protocol is adopted for interoperability by top three IM service providers ?
a) SIP
b) SIMPLE
c) XMPP
d) IMPS

View Answer

Answer: b [Reason:] They allow their users to connect with the other services’ public users for a fee.

4. Which of the following protocol is not a Internet Engineering Task Force standard ?
a) SIP
b) SIMPLE
c) XMPP
d) IMPS

View Answer

Answer: d [Reason:] IMPS is IM communications standard.

5. Point out the wrong statement:
a) All IM clients use peer-to-peer messaging
b) IM software aimed at businesses such as XMPP, Lotus Sametime, and Microsoft Office Communicator use a client/server architecture
c) Instant messaging is as popular in business as it is in personal communications
d) None of the mentioned

View Answer

Answer: d [Reason:] Some IM clients use peer-to-peer messaging.

6. Which of the following IM client allow their users to connect to the different major IM services ?
a) Pidgin
b) Miranda IM
c) Trillian
d) All of the mentioned

View Answer

Answer: d [Reason:] Trillian runs on Windows, Macintosh, IOS (iPhone OS), Android, Blackberry, and inside browsers.

7. Which of the following is also referred to as Short Message Service ?
a) Mini-blogs
b) Micro-blogs
c) Nano-blogs
d) None of the mentioned

View Answer

Answer: b [Reason:] When a service collects your messages in a conversation, it is called a micro-blog.

8. Which of the following is a good example of an SMS service organized into a social network and blog ?
a) Twitter
b) Facebook
c) Instagram
d) None of the mentioned

View Answer

Answer: a [Reason:] It is sometimes referred to as the SMS of the Internet or as a form of Internet Relay Chat (IRC).

9. Which of the following language is used to build message server queue in twitter ?
a) Ruby
b) Scala
c) Java
d) All of the mentioned

View Answer

Answer: b [Reason:] The Twitter Web client was built using Ruby on Rails and deployed on the Ruby Enterprise Edition, with the message queue server written in Scala.

10. Which of the following version of office suite is shown in the figure ?
advanced-cloud-computing-questions-answers-q10
a) Offline
b) Online
c) Online and Offline
d) None of the mentioned

View Answer

Answer: b [Reason:] Glide Digital OS4 is a complete suite with office software, e-mail, and other tools that replicate an online desktop.