 
                 
                InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. | Loops that iterate for fixed number of times is called .......(a) Unbounded loops(b) Bounded loops(c) While loops(d) For loops | 
| Answer» (b) Bounded loops | |
| 2. | Write a php program to print star (*) in a single line? | 
| Answer» <?php for($x = 1;$x < 10;++$x) { print"*\t";} ?> | |
| 3. | What will be displayed in a browser when the following PHP code is executed:<?phpfor (Scounter = 20; $counter< 10;$counter++){echo “Welcome to Tamilnadu “;}echo “Counter is: Scounter”;?>(a) Welcome to Tamilnadu(b) Counter is: 20(c) Welcome to Tamilnadu Counter is: 22(d) Welcome to Tamilnadu Welcome to Tamilnadu Counter is: 22 | 
| Answer» (b) Counter is: 20 | |
| 4. | Which loop evaluates condition expression as Boolean, if it is true, it executes statements and when it is false it will terminate?(a) For loop (b) For each loop (c) While loop (d) All of them | 
| Answer» (d) All of them | |
| 5. | Write a php program to print the students name in the array? | 
| Answer» Example: <?php $Student_name = array("Maglin","Iniyan","Nilani","Sibi","Shini"); foreach($Studentname as $value){echo"Salue<br>"; ?> | |
| 6. | Explain about the parameters in the for loop? | 
| Answer» Parameters: 1. in it counter: Initialize the loop initial counter value 2. Test counter: Evaluated for every iteration of the loop. If it evaluates to TRUE, the loop continues. If it evaluates to FALSE, the loop ends. 3. Increment counter: Increases the loop counter value. | |
| 7. | Which one of the following loop will be executed atleast once?(a) For (b) For each (c) While (d) do while | 
| Answer» (d) do while | |
| 8. | Which loop is used for simple iteration objects? (a) For (b) For each (c) While(d) do while | 
| Answer» While is used for simple iteration objects | |
| 9. | Find the correct statement from the following.(a) For each can be used for variables with a different data type(b) For each can be used with uninitialized variable (c) For each can be used for objects | 
| Answer» (c) For each can be used for objects | |
| 10. | Assertion (A): In for each loop, the array pointer is shifted by one.Reason (R): Whether it reaches the end of the array element(a) A is True, R is correct But R is not correct explanation for A(b) Assertion is True, Reason is False(c) Assertion is false, Reason is true(d) Assertion and Reason are correct and R is the correct reason for A. | 
| Answer» (d) Assertion and Reason are correct and R is the correct reason for A. | |
| 11. | Which one of the following loop has key value pair?(a) for (b) for each (c) while (d) do while | 
| Answer» (b) for each | |
| 12. | Which loop is exclusively available in PHP?(a) For (b) While (c) for each (d) do while | 
| Answer» (c) for each | |
| 13. | Find the Wrong statement(a) For each works on arrays and pointers(b) For each works on arrays(c) For each works on arrays and objects .(d) For each works on objects | 
| Answer» (a) For each works on arrays and pointers | |
| 14. | Find the Incorrect statement(I) For loop works only with arrays (II) For each loop works only with arrays | 
| Answer» (I) For loop works only with arrays | |
| 15. | Which of the following loop works only with arrays?(a) for(b) while(c) for each(d) do while | 
| Answer» (c) for each | |
| 16. | Each segment of the for loop is terminated by(a) , (b) ; (c) :(d) . | 
| Answer» Each segment of the for loop is terminated by ; | |
| 17. | How many types of loops are there?(a) 1 (b) 2 (c) 3 (d) 4 | 
| Answer» There are 4 types of loops. | |
| 18. | Write Syntax of For each loop in PHP? | 
| Answer» for each ($array as $value) { code to be executed; } | |
| 19. | Write Syntax of Do while loop in PHP? | 
| Answer» do { code to be executed; } while (condition is true); | |
| 20. | Write Syntax of while loop in PHP? | 
| Answer» while (condition is true) { code to be executed; } | |
| 21. | Most complicated looping structure is ..........(a) While (b) Do While (c) For (d) None of them | 
| Answer» Most complicated looping structure is For | |
| 22. | What will be the output of the following PHP code?(i) <?phpfor($x = 1;$x < 10; + +$x){print "*\t";}?>(a) ********** (b) ********* (c) *********** (d) Infinite loop(ii) <?phpfor($x = -1;$x < 10; - $x){print $x;}?>(a) 123456713910412(b) 123456713910(c) 1234567139104(d) Infinite loop | 
| Answer» (i) (b) ********* (ii) (d) Infinite loop | |
| 23. | What will be displayed in a browser when the following PHP code is executed:<?phpfor (Scounter = 10; Scounter = 10;$counter = $counter + 5){echo "Hello";}?>(a) Hello Hello Hello Hello Hello(b) Hello Hello Hello(c) Hello(d) None of the above | 
| Answer» (d) None of the above | |
| 24. | Consider the following code<?php$count = 12;do{printf(“%d squared=%d<br/>”,Scount, pow($count,2));} while($count<4);?>What will be the output of the code.(a) 12 squared 141(b) 12 squared=141(c) “12 squared=141”(d) Execution error | 
| Answer» (d) Execution error | |
| 25. | Pick the odd one out related to the parameters of the for loop?(a) in it(b) test (c) text (d) Increment | 
| Answer» text is related to the parameters of the for loop | |
| 26. | How many segments are there in a for loop?(a) 1 (b) 2 (c) 3 (d) 4 | 
| Answer» There are 3 segments in a for loop | |
| 27. | Which counter decides whether the loop should continue or ends?(a) In it (b) Test (c) Increment (d) Decrement | 
| Answer» Answer (b) Test | |
| 28. | Find the true statement from the following.(a) Init counter initialises the loop(b) Increment counter initialises the loop | 
| Answer» (a) Init counter initialises the loop | |
| 29. | Which loop is used if you know in advance how many times the loop should run?(a) For (b) For each (c) While (d) Do-while | 
| Answer» For times the loop should run | |
| 30. | Define for loop in PHP? | 
| Answer» For Loop: For loop is an important functional looping system which is used for iteration logics when the programmer know in advance how many times the loop should run. Syntax: for (int counter; test counter; increment counter) { code to be executed; } | |
| 31. | …….. structures are useful for writing iteration logics. | 
| Answer» Looping structures are useful for writing iteration logics. | |
| 32. | PHP supports four types of looping techniques? (a) for loop (b) while loop (c) for each loop (d) all the above | 
| Answer» (d) all the above | |
| 33. | Compare For loop and for each loop? | 
| Answer» For loop: The for loop is used when you know in advance how many times the script should run. for each loop: The for each loop works only on arrays, and is used to loop through each key/value pair in an array. | |
| 34. | What is For each loop in PHP? | 
| Answer» For each Loop: 1. for each loop is exclusively available in PHP. 2. It works only with arrays. The loop iteration deepens on each KEY Value pair in the Array. 3. For each, loop iteration the value of the current array element is assigned to $value variable and the array pointer is shifted by one, until it reaches the end of the array element. | |
| 35. | Define Looping Structure in PHP? | 
| Answer» Looping Structure: 1. Looping Structures are useful for writing iteration logics. 2. It is the most important feature of many programming languages, including PHP. 3. They are implemented using the following categories, 1. for Loop 2. While Loop 3. foreach Loop 4. Do While Loop | |
| 36. | Write the features Looping Structure? Looping Structure: | 
| Answer» 1. Looping Structures are useful for writing iteration logics. 2. It is the most important feature of many programming languages, including PHP. 3. They are implemented using the following categories: 1. For Loop 2. For each Loop 3. while Loop 4. Do while Loop 1. For Loop: For loop is an important functional looping system which is used for iteration logics when the programmer know in advance how many times the loop should run. Syntax: for (init counter; test counter; increment counter) { code to be executed; } 2. For each Loop: foreach loop is exclusively available in PHP. It works only with arrays. The loop iteration deepens on each KEY Value pair in the Array. For each, loop iteration the value of the current array element is assigned to $value variable and the array pointer is shifted by one, until it reaches the end of the array element. Syntax: for each ($array as $value) { code to be executed; } 3. While Loop: While loop is an important feature which is used for simple iteration logics. It is checking the condition whether true or false. It executes the loop if specified condition is true. Syntax: while (condition is true) { code to be executed; } 4. Do While Loop: Do whileloop always run the statement inside of the loop block at the first time execution. Then it is checking the condition whether true or false. It executes the loop, if the specified condition is true. Syntax: do { code to be executed; } while (condition is true); | |
| 37. | List out Looping Structure in PHP? | 
| Answer» 1. for Loop 2. While Loop 3. For each Loop 4. Do While Loop | |
| 38. | Usage of for each loop in PHP? | 
| Answer» 1. The for each loop works only on arrays, 2. It is used to loop through each key/value pair in an array. | |
| 39. | Write Syntax of For loop in PHP? | 
| Answer» for (int counter; test counter; increment counter) { code to be executed } | |
| 40. | Which loop evaluates condition expression as Boolean, if it is true, it executes statements and when it is false it will terminate? (a) For loop(b) For each loop (c) While loop (d) All of them | 
| Answer» (d) All of them | |