0% found this document useful (0 votes)
149 views8 pages

Technical Test For Candidate

This document contains 26 technical questions for a test. It includes questions about PHP functions, SQL queries, jQuery, databases, and security. Applicants are asked to complete and return the test by the end of the day. They may refer to PHP or SQL documentation for help in answering the questions.

Uploaded by

Manikandan S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
149 views8 pages

Technical Test For Candidate

This document contains 26 technical questions for a test. It includes questions about PHP functions, SQL queries, jQuery, databases, and security. Applicants are asked to complete and return the test by the end of the day. They may refer to PHP or SQL documentation for help in answering the questions.

Uploaded by

Manikandan S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Technical Test

There are a total of 26 questions in this Technical Test. Please complete the test by end of
the day and return it back to us. If you need to refer to the PHP or SQL documentation,
please feel free to do so.

Question 1

Write a PHP function which takes in an array of strings and returns an array of lengths of
all the strings in the given array.

For example, given the array["Nutella","Mars","Snickers","Kinder","Cadbury"] , your function should


return the array[7,4,8,6,7].

Question 2

A palindrome is a string which reads the same left-to-right and right-to-left.

Write a PHP function which takes in a string and returns the length of the string if the
given string is a palindrome and returns false if the given string is not a palindrome.

For example, given the string “aabaa”, your function should return 5. Given the string
“daba”, your function should return false.

Question 3

Write a PHP function which takes in an array of integers and returns the sum of only the
even integers in the given array.

For example, given the array [15,18,3,9,6,2,12], your function should return 38.
Question 4

Write a SQL query which shows the following information for each member in the
members table.

first_name, last_name, city, state

Table: tbl_members

+-------------+---------+

| Column Name | Type |

+-------------+---------+

| member_id | int |

| first_name | varchar |

| last_name | varchar |

+-------------+---------+

member_id is the primary key column for this table.

Table: tbl_addresses

+-------------+---------+

| Column Name | Type |

+-------------+---------+

| address_id | int |

| member_id | int |

| city | varchar |

| state | varchar |

+-------------+---------+

address_id is the primary key column for this table and member_id is the foreign
key which references member_id in tbl_members table.
Question 5

We have 2 tables, tbl_clients table and tbl_invoices table. Write a SQL query to find all the
clients who have no invoices.

Table: tbl_clients.

+----+-------+

| Id | Name |

+----+-------+

| 1 | Susan |

| 2 | Jake |

| 3 | Tom |

| 4 | Peter |

+----+-------+

Table: tbl_invoices.

+----+------------+

| Id | cient_id |

+----+------------+

| 1 | 3 |

| 2 | 1 |

+----+------------+

client_id is a foreign key in this tbl_invoices table and references Id in


tbl_clients table.

For example, the following should be returned for the above data.

+-----------+

| Clients |

+-----------+

| Jake |

| Peter |

+-----------+

Question 6
Our contacts table shown below contains repeated mobile numbers. Write a SQL query to find all the
phone numbers which appear more than once in the table.

+----+---------+

| Id | Mobile |

+----+---------+

| 1 | 92387974 |

| 2 | 92111930 |

| 3 | 92387974 |

+----+---------+

For example, your query should return the following for the above data set:

+---------+

| Mobile |

+---------+

| 92387974 |

+---------+

Question 7

What is a token method in a CSRF attack? write a function in CodeIgniter.

For example, given the csrf_set_hash(), your function should return the random has csrf
key.

Question 8

Write a PHP class that sorts an ordered integer array with the help of sort() function.
Sample array:array(13, -2, 4, 30, 1, 8, -5)

Sample Output:
Array
(
[0] => -5
[1] => -2
[2] =>1
[3] => 4
[4] => 8
[5] => 13
[6] => 30

Question 9

Write a PHP program to create a new string which is 4 copies of the 2 front characters of a
given string. If the given string length is less than 2 return the original string.

Sample Output:

CCCC
JSJSJSJS
A

Question 10

Implement the unique_names function. When passed two arrays of names, it will return an


array containing the names that appear in either or both arrays. The returned array should
have no duplicates.
For example, calling unique_names(['Ava', 'Emma', 'Olivia'], ['Olivia', 'Sophia',
'Emma']) should return ['Emma', 'Olivia', 'Ava', 'Sophia'] in any order.

Question 11

Write a program to print the below format :


159
2 6 10
3 7 11
4 8 12

Question 12

Write a query to get the average salary for all departments employing more than 10
employees.
Sample Output:

Department_id avg(salary) count(*)


50 3475.555556 45
80 8955.882353 34

Question 13

Implement a groupByOwners function that:

 Accepts an associative array containing the file owner name for each file name.
 Returns an associative array containing an array of file names for each owner name,
in any order.

For example, for associative array ["Input.txt" => "Randy", "Code.py" => "Stan", "Output.txt"
=> "Randy"] the groupByOwners function should return ["Randy" => ["Input.txt",
"Output.txt"], "Stan" => ["Code.py"]].

Question 14

Write a program for this Pattern:


*****
*      *
*      *
*      *
*****

Question 15

How to connect multiple databases in CodeIgniter?


Question 16

What are CodeIgniter security methods?

Question 17

What are the XSS security parameters?

Question 18

Differentiate between bind() vs live() vs delegate() methods in jQuery.

Question 19

Explain what the following code will do:


$( "div#first, div.first, ol#items> [name$='first']" )

Question 20

Given the following HTML:


<div id="expander"></div>
and the following CSS:
div#expander{
width: 100px;
height: 100px;
background-color: green;
}
Write code in jQuery to animate the #expander div, expanding it from 100 x 100 pixels to
200 x 200 pixels over the course of three seconds.

Question 21

Explain what the following code does:


$( "div" ).css( "width", "300px" ).add( "p" ).css( "background-color", "blue" );

Question 22

Query to select all records with "bar" in their name?


• SELECT * FROM people WHERE name = "%bar%";
• SELECT * FROM people WHERE name LIKE "%bar%";
• SELECT * FROM people WHERE name IN ("bar");
• SELECT * FROM people WHERE name = "_bar_"

Question 23

What is the main advantage of a clustered index over a non-clustered index?


• It is easier to create and manipulate.
• It requires extra memory but allows for speedy retrieval of records.
• It does not require additonal memory and allows for speedy retrieval of records.
• None of the above.

Question 24

Which of the following is known as a virtual table in SQL?


• SELF JOIN
• INNER JOIN
• VIEW
• NONE

Question 25

SQL query used to fetch unique values from a field?

• SELECT UNIQUE column_name FROM table_name;


• SELECT DISTINCT column_name FROM table_name;
• SELECT column_name FROM table_name WHERE COUNT(column_name) = 1;
• SELECT UNIQUE column_name FROM table_name WHERE COUNT(column_name) =
1;

Question 26

Which statement is false for a FOREIGN KEY constraint?


• Foreign key defines a relationship between two tables.
• Foreign Key is automatically created when two tables are joined.
• Foreign Key uniquely identifies all the records in the referenced table.
• Foreign key may or may not be unique but can be comprised of multiple fields

You might also like