Top Interview Questions and Answers

Top Interview Questions and Answers
Interview Sortout

Browsing "Older Posts"

Jquery noConflict()

By Dhananjay yadav → September 21, 2018
What is noConflict() method in jQuery?
This is very important to differentiate scripts when we are using many JavaScript framework in our project.As we know jQuery uses dollar symbol ($) as shortcut. There are many other popular frameworks are there as Angular JS,Knockout JS,Kendo JS,Backbone JS,Ember ,Vue etc.
Suppose i one of these frameworks is using the $ symbol as shortcut then one of the scripts either jQuery or othe framework implemented parallel may stop working. noConflict is a method to avoid such situation in script.

We can create our self defined symbol or string as shortcut for jQuery. noConflict() return a reference and we can store this reference in a variable.

Example of noConflict() and self defined shortcut:



var jq = $.noConflict();
jq(document).ready(function(){
    jq("button").click(function(){
        jq("p").text("Hi there,Conflict resolved");
    });
});


Most Common Jquery Functions in various Interviews

By Dhananjay yadav →
jQuery is a rich library and a very lightweight framework to provide javascript enhanced and modified functionality to our web page.
This is so popular because it has number of functions events, chaining properties and they make it convenient as well as easy to use.
Find some beautiful functions and their explanations in one line.

show(): display a hidden dom , set a style property display as Block.
hide(): Hide the selector from dom tree, visible on browser.
animate(): Apply animation effetcs with selectors.
empty(): Empty the the dom and also removes the child elements.
remove(): remove selector dom from tree
removeClass():remove class or classes from selectors
addClass():add class or classes to the selectors
toggleClass():add and remove simultaneously
stop():stop the propagation of event.
fadeIn():hide dom with a fading down effect.
fadeOut():display dom with a fadind out effect.
val():get the value of form elements.
text():get the text in dom.
html():get the HTML in dom.
child():find the child elements in dom.
parent():find the immediate parent elelment of the dom.
parents():find the parents of parent of selector in the dome tree .
siblings():find the parellel elements in the dom tree.
slideDown():display the dom with a sliding to downwards effect.
slideUp():hisde the dome with a sliding to up effect.
attr():get the attribute of DOM.
append():add the given object to the selector one after one, in a stack style. Object is added as last child always.
prepend():add the given object to the selector , but the object is added as the first child always.
after():add an object just after the selector.
before():add and object just before the selector.
css():add some inline css properties to the selector.
first():get the first element in the childs.
last():get the last element in the child.
eq():find the object of equal index passed to it.
noConflict():avoid conflicts with other javascript framework using $ as shortcut symbol.

jQuery Events Frequently asked in various Interviews

By Dhananjay yadav →
jquery-interview-questions-answers
Jquery events are attached with some function and function called when event triggers. On a web page actions taken by visitors are events. They can be responded accordingly as click,change,blur,focus,keypress etc. Some common events as categorised as :
Mouse Events : click,dblclick,hover
Keyboard Events : keypress,keydown,keyup
Form Events : change,select,focus,blur
Window : load,scroll,resize

Most Common events and their explanation in one line:

click(): event is triggered when an element is clicked.
change(): event is triggered when the value of a form field is changed.
focus(): event is triggered when a form field is focused.
blur(): event is triggered when a form field is blured.
hover(): event is triggered when moue pointer hover the element.
focusin(): event is triggered when the chield of and element is focused.
focusout(): event is triggered when the chiled of an element is blured.
keydown(): event is triggered when a key from keyboard is pressed down.
keypress(): event is triggered when a key is pressed .keypress event is not fired for ALT, CTRL, SHIFT, ESC.
keyup(): event is triggered when a pressed key is released.
load(): event is triggered when a dom is loaded.
unload(): event is triggered when a dom is unloaded.
mouseenter(): event is triggered when mouse pointer enters the area.
mousedown(): event is triggered when left mouse button is clicked.
mouseout(): event is triggered when mouse pointer leaves the area.
on(): on event is used to add additional handler to dom element.
submit(): event is triggered when form is submitted.
scroll(): event is triggered when the window is scrolled.
select(): event is triggered when the a form element is selected, in combobox or dropdown list.
ready(): event is triggered when the dom is ready and loaded in tree.
resize(): event is triggered when window dimensions are resized.

80 PHP functions asked in any Interview

By Dhananjay yadav → September 11, 2018
This post contains the list of PHP functions that are frequently asked in various interview from freshers as well as experienced candidates. These are the parts of basic and core PHP. One must be familiar with these functions, I have just mentioned the definition in one line for each functions.They are frequently used in our application. Hope you will find this helpful.
  1. strlen() : returns the length of string passed.
  2. stristr() : returns rest of the string after the first occurence of a string in another string.
  3. stripos() : find the position of the first occurence of the string in another string.
  4. strip_tags() : returns string from html tags.
  5. strchr() : find first occurence of a string in another string and returns rest of the string.
  6. str_word_count() : returnd number of words in a string.
  7. str_split() : returns an array of charecters that string contains, when passed to it.
  8. str_replace() : search and replace a substring in a string by another substring.
  9. str_pad() : provide a virtual length to a string. It adds desired charecter to a string to make it up to required length.
  10. str_repeat() : Return a repeated string by a number of times.
  11. str_getcsv() : Parse a string to get the fields for CSV.
  12. rtrim() : remove white spaces from a string from right side.
  13. ord() : When we need to find ASCII value of the first charecter of the string we use ord().
  14. nl2br() : Conver all the new line charecters to BR tag of HTML.
  15. strstr() : returns rest of the string after the first occurence of a string in another string, find only case sensitive string.
  16. strtok() : breaks a strings into substrings
  17. strtoupper() : convert the case of string into uppercase.
  18. strtolower() : convert the case of string into lowercase.
  19. substr() : return a substring from a string of a length and from starting position.
  20. trim() : removes the white spaces from a string from left and right.
  21. ucfirst() : convert the case of first letters of all words in a string to uppercase.
  22. wordwrap() : break lines after a length.
  23. print() : output the result string when passed to it.
  24. print_r() : prints a resources ,object or an array along with the indexes.
  25. unlink() : delete a file from its location.
  26. unset() : set the value of a variable undefined.
  27. isset() : check whether the variable is defined or not.
  28. empty() : check whether an array is empty.
  29. array_chunk() : breaks an array into chunks of small arrays.
  30. array_combine() : combine two arrays of equal size where one is used for keys and another one is used for values.
  31. array_count_values() : count and returns the number of values of an array
  32. array_diff() : returns an array having difference between two arrays.
  33. array_flip() : flip key and value simultaneously.
  34. array_filter() : filter the values of an array based on a callback function.
  35. array_key_exists() : returns true if a key exists in an array.
  36. array_keys() : returns the array of keys from an array.
  37. array_map() : apply some operation on each value of an array and return a new array with modified values.
  38. array_merge() : merge the values of two array while retaining their keys.
  39. array_merge_recursive() : merge multidimensional arrays.
  40. array_push() : add a new value in an array at the end.
  41. array_rand() : select some random keys from an array.
  42. array_replace() : replace values in an array from the values in another array.
  43. array_reverse() : reverse the order of array and return new array.
  44. array_search() : search a value in an array and return the key of the value.
  45. array_shift() : remove the first element in an array.
  46. array_sum() : sum up all the values in an array.
  47. array_unique() : remove all the replicated values in an array.
  48. array_values() : returns an array of values with numeric index.
  49. array_walk() : Go to each value and run over an user defined function.
  50. array_walk_recursive() : Does the same recursively for an array.
  51. compact() : The compact() function creates an array from variables and their values.
  52. asort() : Sort an array values in ascending order.
  53. arsort() : Sort an array values in descending order.
  54. in_array() : returns true if a value find in an array.
  55. key() : return the key from the current pointer position.
  56. krsort() : sort and array based on keys and in descending order.
  57. ksort() : sort and array based on keys and in ascending order.
  58. range() : create an array from the range passed to it.
  59. date_create() : create a new dateTime object.
  60. date_create_from_format() : Create a user defined date from given format.
  61. date_diff() : returns difference between two dates.
  62. date_sub() : suntracts some period of time from a given date.
  63. date() : output the current date and time based on parameters given to it.
  64. gettimeofday() : output current time.
  65. gmmktime() : output UNIX time for GMT.
  66. localtime() : returns local time as UNIX timestamp.
  67. strtotime() : convert a string having datetime information into UNIX date.
  68. time() : eturn the current time.
  69. ceil() : returns the next interger value of the floating number passed to it.
  70. floor(): returns the next lowest integer value
  71. abs() : returns the absolute value passed to it.
  72. base_convert() : convert the base of number system.
  73. is_nan() : check whether a value is Not a Number.
  74. is_infinite() : check wherther a value is Infine.
  75. max() : find the max value from an array.
  76. min() : find minimum value from an array.
  77. mt_rand() : based on Mersenne Twister algorithm creates a random number.
  78. rand() : generate a random number
  79. round() : returns a floating point number up to a particular place of decimal point.
  80. sqrt() : returns the square root of the value passed to it.

Hooks in CodeIgniter

By Dhananjay yadav →

Hooks in CodeIgniter

In code igniter hooks are the points before and after the execution where we can call some specific functions. These functions are called hooks and points where we call hooks are called hook point. Hooks are usefull when we have to make some changes throught the application , then we can do this without hacking all the files, just adding one hook at appropriate point. We can modify the way of usual rendering in code igniter application. So hooks facilitates modification in functionality without changing the core.

How we can use a hook in code igniter framework?
Before we use any hook in application we need to enable the hook in config.php file.Set the enable_hook config variable : TRUE,

$config['enable_hooks'] = TRUE;


The framework provide number of Hook Points to ease the development and modification in application:

[1]pre_system:
The pre_system is called very early during system execution. Only the benchmark and hooks class have been loaded at this point.

[2]pre_controller:
As per the name just called before any of your controllers being called. When all the base classes are loaded, routing and security checks are done a pre_controller hook is called.

[3]post_controller_constructor:
The hook is called just after the controller class instantiated but none of the method is called.


[4]post_controller:
Called immediately after your controller is fully executed.

[5]display_override:
We have the _display() function in our core and we use it to render our view on browser after execution of all programms.
display_override allow use to display our own content at desired places.

$this->CI => get_instance();
$this->CI->output->get_output();


[6]cache_override:
We can call our own function instead of _display_cache() function using the cache_override hook. We can define our own cache display mechanism.

[7]post_system:
At the end of the system execution when final rendering is done post_system is called.



Define a hook :
A hook is defined in the hooks.php file located at application/config

Example for define a pre_controller hook:

$hook['pre_controller'] = array(  
            'class' => 'Classname',  
            'function' => 'functionname',  
            'filename' => 'filename.php',  
            'filepath' => 'hooks',  
            'params' => array('element1', 'element2', 'element3')  
            );  





Wordpress Dashboard - Tutorial 4

By Dhananjay yadav → September 10, 2018

Admin Login

  • Give the user name and password .
  • Check the remember box as the browser will remind the login and password next time.

Dashboard area contains the following main tools and links:
  • Welcome section
  • Main menu(side menu)
  • Top menu
  • Admin area
  • Screen option
  • Help option
  • Quick draft section
  • At a glance section
  • Activity section



Welcome Section
  • This section has some important links which used frequently.
  • We can customize our site look as we click on Customize Your Site button.
  • Direct links to add an about page, to write the first blog.
  • We can turn on/turn off comments by external user on our posts from here.
  • We can visit our menu and widget systems from the link given.  



Screen Options:
  • Screen option shows a group of check boxes.
  • Each check box is for a particular section.
  • If it is checked the section is on the screen on the dashboard .
  • Unchecked boxes hide the section from dashboard.
  • Ex - we have to hide the Welcome section from screen. We will uncheck it.
...


WordPress Installation : Tutorial 3

By Dhananjay yadav →


WordPress Installation
Before install a WordPress we should ensure that we have already created a database , where we have to create the WordPress tables with a prefix name .Default is prefix is wp_. We should have the following information as we are going to install the WordPress:
  • Database Name: wordpress
  • User name: root
  • Password: by default blank
  • Hostname:localhost
Steps:
  1. Put the database name as you have created in the database field. It appears “wordpress” by default.
  2. Give the mysql user name, which is root by default.
  3. Give the password of mysql , if you have’n define , then let the password field blank.
  4. Give the host name as running on default port, localhost.
  5. Give a prefix for the table name , which are being install in database.
     
A wp-config.php file is created, containing the information about database, username, password etc, at the time of installation.

Wordpress Minimum Requirement : Tutorial 2

By Dhananjay yadav →


Chapter:2-Before Installation
Minimum Requirement of a system to run the WordPress
  • We need a server to run the PHP script, because PHP is a server side script and WordPress is based on PHP.
  • WAMP Server which is-Windows Apache MySQL PHP
  • Download Source code of WordPress from: http://wordpress.org/downloads
  • Latest version of WordPress is wordpress-3.8.1 (as on 03-04-2014)
  • Latest of WAMP is 2.2 having
    • Apache 2.2.22
    • Mysql 5.5.24
    • PHP 5.3.13
    • PhpMyadmin 3.4.10.1
  • Apache is an open source web server , which is available in free. Apache is the one of the most popular and the most lovable web server by the web developers across the world.
  • Separately we can download from: http://www.apache.org
  • MySQL is the most preferred open source RDBMS .
  • Very identical to MSSQL and other RDBMSs.
  • PHP(PHP Hypertext Preprocessor) is an open source server side scripting language having the features of OOPS and syntax similar to C Programming and Perl.
  • PHP provide a rich library to manipulate data and make most of the complicated data operations easy.

WordPress Inroduction : Tutorial 1

By Dhananjay yadav →


Chapter1: WordPress Inroduction
What is WordPress:
  • WordPress is a world famous Open Source CMS. Based on PHP as an open source server side scripting language.
  • WordPress is a free and open source blogging tool and a content management system (CMS) based on PHP and MySQL, which runs on a web hosting service.Features include a plug-in architecture and a template system.
  • WordPress is used by more than 18.9% of the top 10 million websites as of August 2013. WordPress is the most popular blogging system in use on the Web, at more than 60 million websites.
  • Architecture of template:


History:
  • WordPress started in 2003 with a single bit of code to enhance the typography of everyday writing and with fewer users than you can count on your fingers and toes. Since then it has grown to be the largest self-hosted blogging tool in the world, used on millions of sites and seen by tens of millions of people every day.
  • It was first released on May 27, 2003, by its founders, Matt Mullenweg and Mike Little,as a fork of b2/cafelog. As of February 19, 2014, version 3.8 had been downloaded more than 20 million times.The license under which WordPress software is released is the GPLv2 (or later) from the Free Software Foundation.


Content Management Bystem (CMS) 
  • A Computer Application that allows publishing, editing and modifying content  as well as maintenance from a central interface.
  • CMSs are often used to run websites containing blogs, news, and shopping. Many corporate and marketing websites use CMSs. CMSs typically aim to avoid the need for hand coding but may support it for specific elements or entire pages.
  • The function and use of content management systems is to store and organize files, and provide version-controlled access to their data. CMS features vary widely. Simple systems showcase a handful of features, while other releases, notably enterprise systems, offer more complex and powerful functions. Most CMS include Web-based publishing, format management, revision control (version control), indexing, search, and retrieval. The CMS increments the version number when new updates are added to an already-existing file.


Architecture of wordpress template:

CakePHP Advance : Most Common Interview Questions and Answers

By Dhananjay yadav → September 6, 2018
cakephp

What is HMAC?
HMAC means Hash-based Message Authentication Code . This is a authentication code used with combination of an encryption key and a hash function.


What is Asset.cacheTime ?
Asset.cacheTime sets the asset cache time. This determines the http header Cache-Control’s max-age, and the http header’s Expire’s time for assets.


What is DSN?
DSN is Data Source Name. A connection string format that is formed like a URI. CakePHP supports DSN’s for Cache, Database, Log and Email connections.

What is PaaS?
Platform as a Service. Platform as a Service providers will provide cloud based hosting, database and caching resources. Some popular providers include Heroku, EngineYard and PagodaBox.

How we can use Cache in CakePHP?
Caching in CakePHP is facilitated by the Cache class. This class provides a static interface and uniform API to interact with various Caching implementations.


What types of Caching Engine does CakePHP provide?
1-FileCache-uses files.
2-ApcuEngine - uses the PHP APCu extension.
3-Wincache - uses the Wincache extension.
4-MemcachedEngine - uses the Memcached extension.
5-RedisEngine - uses the phpredis extension.


What is the default cache file path?
Path to where cache files should be saved. Defaults path is system's temp dir.

How to read a Cache Object in CakePHP?
Using Cache class we can read the object as given below:

$posts=Cache::read('posts');



How to write a Cache Object in CakePHP?
Using Cache class we can write the object as given below:

    Cache::write('posts',$posts);


How to remove an object completely from Cache?
Using Cache class we can delete the object as given below:

    Cache::delete('posts');


Can we read,write and delete multiple objects at a time?
Yes , we can do cache operations on multiple objects using functions like:

    Cache::deleteMany(['posts','comments','users']);
    Cache::readMany(['posts','comments','users']);
    Cache::writeMany(['posts'=>$posts,'comments'=>$comments,'users'=>$users]);


What is difference between Cache:clear() and Cache::delete() ?
Cache:clear() removes the values from associated with keys and empty them to hold new values, where as Cache:delete() removes the object completely from cache.

How can we disable or enable cache glaoblly in CakePHP?
We don't need to disable all Cache read & writes and to expiration. We can do this using enable() and disable():

    Cache::disable();
    Cache::enable();


What are the different log levels in CakePHP?
1-Emergency: system is unusable
2-Alert: action must be taken immediately
3-Critical: critical conditions
4-Error: error conditions
5-Warning: warning conditions
6-Notice: normal but significant condition
7-Info: informational messages
8-Debug: debug-level messages


What is CakeRequest?
CakeRequest is the default request object used in CakePHP. By default, CakeRequest is assigned to $this->request, and is available in Controllers, Views and Helpers.


What are different ways to access the parameters in CakePHP?
Following ways :

$this->request->controller;
$this->request['controller'];
$this->request->params['controller'];


How can we access the Passed Argumets from URI in CakePHP?
Way to access the Passed Argumets in CakePHP as:

$this->request->pass;
$this->request['pass'];
$this->request->params['pass'];


How can we access the Named Parameters from URI in CakePHP?
Way to access the Named Parameters in CakePHP as:

$this->request->named;
$this->request['named'];
$this->request->params['named'];


How can we read Query String Parameters?
We can read these paameters using Cake Request Handler :

  // url is as : /posts/index?page=1&sort=title
  $this->request->query['page'];


How can we detect the request type?
We can check any request as :
$this->request->is('post');
$this->request->is('get');
$this->request->is('ajax');
$this->request->is(['put','post']);


How to detect environment in CakePHP?
$this->request->addDetector(
    'post',
    array('env' => 'REQUEST_METHOD', 'value' => 'POST')
);


How to detect pattern value in CakePHP?
$this->request->addDetector(
    'iphone',
    array('env' => 'HTTP_USER_AGENT', 'pattern' => '/iPhone/i')
);


How to detect options in CakePHP?
$this->request->addDetector('internalIp', array(
    'env' => 'CLIENT_IP',
    'options' => array('192.168.0.101', '192.168.0.100')
));


How to detect callback in CakePHP?
$this->request->addDetector(
    'awesome',
    array('callback' => function ($request) {
        return isset($request->awesome);
    })
);



How to find the root directory of the the application?
$this->request->webroot;

How to find the base path in CakePHP?
$this->request->base;

How to find the full address of the current request in CakePHP?
$this->request->here;

CakePHP Advance Interview Questions and Answers For Experienced and Freshers

By Dhananjay yadav → August 25, 2018

(1). What is the default cache Engine in CakePHP?
File Engine is the default cache Engine in Cake PHP.

(2). How many types of cache does CakePHP Support?
Different types of cache supported by CakePHP:
1-FileCache
2-ApcCache
3-Wincache
4-XcacheEngine
5-MemcacheEngine
6-RedisEngine

(3). How mamy types of Associations are there in CakePHP Models?
There are four association types in CakePHP:
Relationship Association type Example
one to one hasOne A user has one profile.
one to many hasMany A user can have multiple recipes.
many to one belongsTo Many recipes belong to a user.
many to many hasAndBelongsToMany Recipes have, and belong to, many ingredients.

(4). How to create association?
Model association example:
class Toy extends AppModel {
    public $hasOne = 'Profile';
    public $hasMany = array(
        'Toy' => array(
            'className' => 'Toy',
            'conditions' => array('Toy.approved' => '1'),
            'order' => 'Toy.created DESC'
        )
    );
}
?>

(5). How to create Pagination in List view?
Cake PHP has a built in component 'Paginator'. We can use this Component to create Pagination.

(6). How to destroy an association?
Use 'unbindModel' to destroy a particular type of association.
$this->Leader->unbindModel(
        array('hasMany' => array('Follower'))
    );


(7). Give an example of LEFT JOIN using CakePHP ORM?
LEFT JOIN example using cake php ORM:
$options['joins'] = array(
    array('table' => 'channels',
        'alias' => 'Channel',
        'type' => 'LEFT',
        'conditions' => array(
            'Channel.id = Item.channel_id',
        )
    )
);
$Item->find('all', $options);

(8). How to prevent the default View and Layout to be rendered?
We can set the default view and default Layout variable to false.
$this->layout='';
$this->autoRender = false;

(9). What is layout in CakePHP?
View files that contain presentational code that wraps many interfaces in your application. Most views are rendered inside a layout.

(10).  What Is A Component In Cakephp?
Components are packages shared between controllers. They are useful when a common logic or code is required between different controllers.

(11). What are Components Used in Cakephp?
1-Security
2-Sessions
3-Access control lists
4-Emails
5-Cookies
6-Authentication
7-Request handling
8-Scaffolding

(12). What Is A Behavior?
Behaviors in CakePHP are associated with Models.Behaviors are used to change the way models behaves and enforcing model to act as something else.

CakePHP Interview Questions and Answers

By Dhananjay yadav → July 1, 2018

What is CakePHP ?
CakePHP is an open-source free web framework based on MVC pattern and written in PHP scripting Language for rapid web development.

What is MVC in CakePHP?
Model view controller (MVC) is an architectural pattern used in software engineering.
Model: Handle database related functionality, manipulating database related query like add, edit , delete.
View: Design parts written here (HTML+PHP)
Controller: Business Logic goes here

What are controllers?
A controller is used to manage the logic for a part of your application. Most commonly, controllers are used to manage the logic for a single model. Controllers can include any number of methods which are usually referred to as actions. Actions are controller methods used to display views. An action is a single method of a controller.


List some features of CakePHP framework ?
Top features of CakePHP framework
1-MVC Architecture
2-Zero configuration
3-Inbuilt validation
4-ACL Functionality and Security
5-CRUD scaffolding
6-Easily extendable with plug-ins
7-Quick and flexible


What are Hooks in CakePHP?
CakePHP hooks are callback functions that are called before or after a model operation and defined in models.
List of some Hooks functions provided by CakePHP.
1-beforeFind
2-afterFind
3-beforeValidate
4-afterValidate
5-beforeSave
6-afterSave
7-beforeDelete
8-afterDelete
9-onError


What is default function for a controller?
function index() is default function in controller.

What is a Element?
Element in cakephp are smaller and reusable bits of view code. Elements are usually rendered inside views.

What Is Scaffolding In Cakephp?
Scaffolding is a technical way that allows a developer to define and create a basic application that can create, retrieve, update and delete objects.

How To Get Current URL In CakePHP?
Simple using the following bit of code:
 
  $this->here;
 

How can you make urls search engine friendly while using cakephp?
It’s an automatic task that is done by cakephp.

How cakephp URL looks in address bar?
http://example.com/controller/action/param1/param2/param3

What is Composer? How to create a CakePHP Project using Composer?
Composer is a tool for managing project dependencies. You can create a CakePHP project using Composer by running below commands on terminal.

 
  php composer.phar create-project --prefer-dist cakephp/app my_app_name
 

How To Get Controller Name In CakePHP Views?
Get controller name in CakePHP:
 
  $this->request->params['controller'];
 


What is a Helper in CakePHP?
Helpers in CakePHP are associated with Presentation layers of application.Helpers mainly contain presentational logic which is available to share between many views, elements, or layouts.


What are are drawbacks of cakephp?.
The learning curve, and it loads full application before it starts your task. Its not recommended for small projects because of heavy structure.


What is the name of Cakephp database configuration file name and its location?
Default file name is database.php.default.
Its located in "/app/config/database.php.defaut"


What is habtm?
Has And Belongs To Many is a kind of associations that can be defined in models for retrieving associated data across different entities.

List some database related functions in cakephp.
find, findAll , findAllBy , findBy , findNeighbours and query.

AJAX Interview Questions Answers

By Dhananjay yadav → June 29, 2018
AJAX Interview Questions Answers

What is AJAX?
Full form of AJAX is : Asynchronous JavaScript And XML.
AJAX facilitate a web pages to be updated asynchronously by exchanging data with a web server in background. It can update the webpage without reloading the whole page.

What are the main components that are used by AJAX?
AJAX components are :
1-A browser built-in XMLHttpRequest object
2-JavaScript and HTML DOM


What is XMLHttpRequest Object?
The XMLHttpRequest object can be used to request data from a web server without refreshing the whole page.It can send data to server in background and can request and receive data in background.


What are the request type used by XMLHttpRequest Object?
open() : It specify the type of request GET or POST
send() : Sends the GET request to the server
send(string) : Sends the POST request to the server

Give an Example of jQuery AJAX call.
A POST method AJAX example in jQuery:

  var empId = $("ul .emp").first().attr("id");
  var request = $.ajax({
    url: "myajaxcall.php",
    type: "POST",
    data: {id : empId},
    dataType: "json"
  });

  request.done(function(response) {
    console.log(response);
  });

  request.fail(function(jqXHR, ajax_status) {
    alert( "Request failed: " + ajax_status );
  });
 

What is difference between xhr.status and xhr.readyState.
xhr.status : used to determine whether the request was successful or not.
xhr.readyState : the state of the request'
xhr.readyState zero(0) means "has not yet been sent"
xhr.readyState zero(4) means "complete and response received"
The server provides the status, while the user agent provides the readyState.











Top 10 Codeigniter Interview Questions and Answers for Experienced

By Dhananjay yadav → May 31, 2018


1- What is hook?
CodeIgniter’s Hooks feature modify the core functionalitis of the framework without changing the core files. For example, If you want to run a script right before your controllers get loaded, or right after or at any other location, you can use Hook.

2- How many types of hooks are there in Code Igniter?
There are 7 availabe hook points:

pre_system :
Called very early during system execution. Only the benchmark and hooks class have been loaded at this point. No routing or other processes have happened.

pre_controller :
Called prior to controllers being called. All base classes, routing, and security checks have been done.

post_controller_constructor:
Called after controller is instantiated, but prior to any method calls happening.

post_controller:
Called after the controller is executed.

display_override:
Overrides the _display() method, used to send the finalized page to the web browser at the end of system execution. This permits you to use your own display methodology. Note that you will need to reference the CI superobject with $this->CI->get_instance() and then the finalized data will be available by calling $this->CI->output->get_output().



cache_override:

Enables you to call your own method instead of the _display_cache() method in the Output Library. This permits you to use your own cache display mechanism.

post_system:
Called after the final rendered page is sent to the browser, at the end of system execution after the finalized data is sent to the browser.

Creating a hook :
$my_hook=array(
'class' => 'YourClassname',
'function' => 'your_function_name',
'filename' => 'your_filename.php',
'params' => array('p1', 'p2')
'filepath' => 'hooks', );
$hook['pre_controller'] = $my_hook;

3- Can we use multiple call to same hook?
Yes , we can use multiple call to same hook. Then We have to use multidimentional array:
$hook['pre_controller'][]= $hook_one;
$hook['pre_controller'][]= $hook_two;

4- What are the benifites of using hook in an application?
-We can modify core functionalitis without touching the core files.
-We can generate derired output without changing the view files.
-we can make a hook for recurring calls , like including footer and header in each function, without calling them in each controller function.
-we can create a script to minify the code before excecution take place.
-We can easily implement security checks, privacy, session, cache using hooks and can seperate these implementation from the main functionalitis.

5- WHat is HMVC?
HMVC is a Modular version of MVC. In this system we can implement modules for particular purpose. We may have put out controller , views and model in different modules. All these modules will be available in modules folder in application. HMVC stands for Hierarchical Model View Controller.



6- What is a module?

A module is a part of application and a full featured block which is implemented on HMVC pattern. A module contains its own Model, View and Controller. Although these resources can be shared with other modules.



7- What is difference between Library and Helper?


A CodeIgniter helper is a set of related global functions, you can call them any where in application. Once you load the helper file you can directly call the function. Basically the helper is procedural.

But a Library is a class, which you need to make an instance of the class. Once the library is loaded, we need to use $this operator to call the Library function. This is Object Oriented.




8- What is Routes in Code Igniter Framework?

Routing is the communication between URI and Controller. Routing decides the controller calls and parameters in code igniter. We can overwrite the routing rules in routes.php file.


9- How to use or enable libraries CodeIgniter?
We can initialize the library in controllers as given below:
$this->load->library('my_library_class');

10- Why CodeIgniter is a loosely coupled mvc framework?
CodeIgniter is called a loosely coupled mvc because, it provides unlimited flexibility to developers. It allows us to write and execute our custom codes, library, helpers. We can use call model and controllers functions in views and also can write custom code on views. It works like a core php when some one is going to manipulate it and on the other side it provide a modular structure to our application, XSS and CSRF functionalitis. It provides us lots of inbuilt library and also compatible with many more custome libraries. It never restricts us to write and execute any code.

CSS Interview Questions and Answers

By Dhananjay yadav → April 2, 2018
What is CSS?
CSS stands for Cascading Style Sheet. CSS is applied to HTML page to improve the design, color, and attributes of HTML elements.

What are the selectors in CSS?
Selectors are the references to HTML block, on what the CSS rules to be applied. We can have class, id, HTML tag etc.

How to create a style sheet?
Create a plain text file and named it with .css extension, like "style.css"

How can we link a style sheet to an HTML page?
We can link a seperate style sheet in a html page, using LINK tag, inside HEAD of html. For example

What is inline CSS?
When CSS rules applied to elements in the tag itself using style attribute of DOM. This is not a good practice.

Why inline CSS is not good for a website?
It affects the DOM visibility on search engines. In line, CSS is treated as content by search engines and that is not good for the health of site also. Also lowers the page speed.

What are the common attributes of HTML elements?
Most common attributes of HTML elements are :
-style
-title
-height
-width
-src
-alt
-href
-bg-color

What is !important?
It is used to apply the CSS rule forcefully. It ignores any other rule written for the selector.

What is viewport?
The viewport is the screen size of the device, that used to view the webpage. It refers to the visible area or resolution of the screen.

What is a responsive web page?
A webpage which is compatible with all the devices and screen size is responsive. A responsive web page adjusts content according to the screen size and manages the content in the different layout defined for the devices. We have many CSS frameworks that can be used to create a responsive webpage. For example Bootstrap.

What is media query?
A media query is the conditional rules to apply on a webpage. We use @media and some condition, and when the condition occurs, rule starts working. We use @media for printing, responsive, device detection etc.

What are the benefits of external style sheet?
Benefits of External Style Sheet:
- Clean and Clear structure
- A common rule for similar elements
- All the rules are placed in a single file so we can modify it easily or can add new rules.
- Since HTML DOM tree is clear so it will boost the page speed as well as search engine visibility.

What is a class?
A class is an attribute of HTML elements. We can put some value in class attribute and then we can apply CSS rules on these classes. We can reuse these classes in other HTML elements.

What is ID?
ID is an attribute of HTML elements.A web page can have many IDs but no two IDs can be same. ID should be unique.

How to import CSS rules from another style sheet?
Yes, we can import CSS rules from another style sheet. For example :

@import url("assets/css/style.css");


What are most commonly used CSS framework?
There is a number of frameworks available for CSS rules. Some of them are as:
-Bootstrap
-Foundation
-Skeleton
-Kube

In how many ways can we apply the style to HTML?
We can directly write CSS rules in tags, that is inline CSS rule.
We can write CSS rule in "style" tag in an HTML page.
We can add a separate style sheet.

What is z-index in CSS rule?
z-index is the position of an element in the z-axis of coordinate.This specifies which element should appear on top.

What is display in CSS rule?
the display is for visibility and layout options. We can set any type of display options for any element. If we set to display as "none", It will not render on view, but It will be a part of HTML DOM.

Top jQuery Interview Questions and Answers

By Dhananjay yadav → March 26, 2018
What is jQuery?
jQuery is a Javascript library which uses usage of Javascript very easy.We can handle events, manage CSS properties, DOM element, animation and many more utilities using jQuery library.It is an opensource. It is used by Microsoft, Google, IBM and almost the big players in software industries.

What are selectors?
jQuery selectors are the tool to identify the HTML elements and to manipulate properties. for example:
$(".name") : Class selector
$('#logo') : ID selector
$("button") : tag selector
$(this) : current dom selector

What are the selectors that we use in jQuery?
We use the following selectors in jQuery:
-Tag
-Class
-Id
-all (*)
We can derive more selectors using these main selectors.

What is an event?
An event is a user action. When a user interacts using UI it has to make many clicks, drag, drop, mouse over, change drop down, keypress actions, these actions are recognized by jQuery.

What are the common events that user make?
Most common events make by users are :
-click
-mouseover
-keypress
-keydown
-change
-input
-drag
-drop
-blur
-dblclick (double click)
-mouseenter


What is toggle()?
toggle() is a function which provides switching functionality between two actions, functions, properties etc. Suppose we can show and hide an element using toggle function.

What is callback?
A callback is a function which is called after when execution finished. We have to specify which function we have to call after a particular execution.

What is alert()?
alert() is used as a callback to show some warning, notification or error.

$("button").click(function(){
        alert("Clicked on button");
});

What is chaining in jQuery?
Chaining is calling of multiple functions in a single statement. for example :
$(".button").css("color", "#ececec").slideUp(1000).slideDown(2000).hide();

How to get value or text of an HTML element?
Since we know jQuery can manipulate HTML DOM, we can use functions to get value, text or html block inside an HTML element. For example

$('.first_name').val();  //geting value in input box having class as first_name

$('p').html();   //getting html inside a 'p' tag

$('textarea').text();  //getting text inside a textarea


How can we set values or HTML element?
very similar to getting the value, we can set values to elements. For example:

$('.first_name').val('Interview Sortout Blogs');  //geting value in input box having class as first_name

$('p').html('My blog is based on interview');   //getting html inside a 'p' tag

$('textarea').text('This blog is awesome. You are doing a verygood job,Interview Sortout');  //getting text inside a textarea


How to add or remove class from a HTML element?
jQuery have functions to add or to remove classes from an HTML elements. Please see the following examples:

$('button').addClass('btn-danger');
$('button').removeClass('btn-danger');


How to check that an element has a class?
We can use function hasClass().If class found it returns true, other wise returns false.

if($('button').hasClass('btn-danger')){
 alert('Button class is btn-danger');
}


What append() and prepend() functions do?
append() function , adds an HTML block after(at the end) a selector. For example :
$('p').append('Interview Sortout');

prepend() method, adds a block before or at the beginning of the selector. Example:

$('p').prepend('

Interview Sortout

');

What does parent() method do?
parent() method select the direct parent or immediate ancestor that is next to selector.

What does parents() method do?
parents() select all ancestors , the elements including parent of parent.

What childre() do?
children() method select the immediate child of the selector.

What does find() method do?
find() method search for the selector passed and selects from all the children of selector.

What does siblings() method do?
sibling() method returns all the elements having parralle relationship with selector. We can call them siblings.

How to call AJAX in jQuery?
An AJAX call example in jQuery:

var $post = $.ajax({
  url: "example.php",
  type: "POST",
  data: {id : product_id, product_name:product_name},
  dataType: "json"
});

$post.done(function(msg) {
  $("#log").html( msg );
});

$post.fail(function() {
  alert( "Request failed: Request Has been failed" );
});


More Java Script Related Interview questions and answers
  1. JSON Interview Questions and Answers
  2. Basic Java Script Interview Questions and Answers

Drupal Interview Questions and Answers

By Dhananjay yadav →

What is Drupal?
Drupal is an open source Content Management System and used for Complex websites. It has great flexibility of functionality and modularity. We can design our website using the core of Drupal and we can manage content on pages easily. Nowadays Drupal is used for e-commerce stores, blogging, business sites, college and universities websites.

What are the main features of Drupal?
Main features of Drupal are listed as:
-Open Source
-Flexible and Robust CMS in comparison to Others.
-Provide Security layer.
-Easy to manage Content.
-Fields and Blocks that are the most flexible assets of Drupal.

How Drupal is different from other CMSs available as opensource?
Drupal has a complex structure, and a heavy core so it is not suitable for small websites. It is secure than any other CMS.It has a great functionality to manage content and visibility. It provides a robust user management module in core.

What is the .info file in a Drupal theme?
This is the configuration setting of the Drupal theme. A .info file is a static content and settings are written here as key=value format. Each line has a different key and value for that. Metadata, style sheets, JavaScripts, block regions and more can be defined here. It is used for theme and not for the module.

What is a theme?
The theme is a collection of files to construct the layout. A Drupal theme contains following important elements:
- Configuration file (.info)
- Templates file (.tpl.php)
- Stylesheets
- sub-themes

What is Module in Drupal?
A module in Drupal is a collection of PHP files to provide some additional functionality to Drupal site. A module can access all the core functions and variables of the Drupal.

What is Block?
Blocks are the layout elements. A block defines that what particular content should be displayed at what place in the layout. It is a box in the content area.

How can we add modules to the core?
We can upload compressed files of the module or we can directly import from the remote URL.

What are the regions?
Regions are the layers defined by theme to represent the content area. For example footer, sidebar, navigation etc.

What is a node?
All the contents are treated as a node in Drupal. A node is a chunk of content. We create content, custom content using node module.

What is taxonomy?
Taxonomy is used to organize Metadata, tags, categories in Drupal. It a feature of Drupal core. It is used to categorize the content of the website. We can use tags to connect the content.

What is sub-theme?
A sub-theme is child theme. It inherits the resources of the Parent theme. It can be chained. A sub-theme can be a child of another sub-theme. All the styles sheets and javascript inherited by sub-theme.

What is service.yml?
service.yml placed in the root directory in and all the services are defined here.

What are properties of services?
Services may have following properties:
-abstract
-alias
-tag
-arguments
-calls
-class
-factory
-file
-public
-scope

What is settings.php?
This is the global settings of the site.Tthe database, URL structure, salt, encryption etc all the variables are defined here.

What is clean URL?
SEO friendly URLs in Drupal is clean URL.We can enable or disable it.

How can we manage clean URL in Drupal?
We can enable or disable clean URLs by following steps:
-navigate to Administer > Configuration > Search and metadata > Clean URLs
-Wait for the automated Clean URLs test to run.
-Check or uncheck the Enable clean URLs checkbox
-Click "Save configuration"

What is URL alias?
We can add our custom URL in place of "node". It makes URL clean and SEO friendly.

What does cron do in Drupal?
Cron deletes temporary files and trigger the search module to index the content on the site.It pings modules to get updates.

What is Report in Drupal?
Reports modules collect the site health report and logs.It does the following task:
-Recent log entries
-Top 'access denied' errors
-Top 'page not found' error
-Available updates
-Status Report
-Site statistics

What is the status report?
Here you can find a short overview of your site's parameters as well as any problems detected with your installation.

What is Recent Log entries?
The Database Logging module logs system events in the Drupal database. Monitor your site or debug site problems on this page.

What are the content types in Drupal?
Contents are categorized into 2 basic categories:
1- Basic pages
2- Articles

What is Basic page content?
Basic Page is the landing pages for a site, that rarely change. If we are creating About us, Contact us, Services, Team pages then we have to choose Basic Page type content.

What is Article type content?
Article type is a regular blog post on the site. We can select Article if we are writing an article or blog posts related to latest updates, hobbies etc.


20 Android Interview Questions and Answers : Basic Level

By Dhananjay yadav → March 24, 2018
Android Interview Questions and Answers

What is Android?
Android is an operating system based on a modified version of Linux kernel and other open source software which was developed by Google and later the Open Handset Alliance (OHA). Contrary to what most of the people think, Android is not a programming language. In other words, Android is an open source operating system used for devices like smartphones and tablet computers.

What are the components of Android application?
  • Activities:
  • Intent
  • Services
  • Broadcast receiver
  • Content providers


What languages do android support?
Android system most commonly uses JAVA language, though the native C/C++ can also be used to write a program in android.

How Androidpes of Android applications are there?
There are two types of Android applications, namely:
a) Hybrid Applications
b) Native Applications

Who is the founder of android?
Android was invented by Andy Rubin, Rich Miner, Nick Sears and Chris White in the year 2003 in Paolo Alto, California.

What do you understand by the term APK?
APK stands for Android Package, an APK file can be installed on an android device just like installing software on windows. APK files are kind of archive files, to make an APK file an android program is compiled and then all its contents like assets, resources, and certificates are packaged into one file.


What is AAPT?
AAPT stands for Android Asset Packaging Tool, it is a tool that provides developers the ability to deal with zip-compatible archives including creating, extracting and viewing the contents.

Give some disadvantages of Android OS?
Android is categorized a heavy operating system and most apps tend to run in the background even when not in use.
High power consumption rate is inherent to Android-powered devices.
Android is not considered among the safest types of OS and is prone to malware.
High data consumption due to background running of applications.

What are the essential items in an Android application?
Following are the essential items for an android application:
  • AndroidManifest.xml
  • build.xml
  • bin/
  • src/
  • res/
  • assets/


What is Android Studio?
Android Studio is the primary IDE for native Android application management. It is the official Integrated Development Environment for Google’s Android operating system.

What is the earliest version of Android?

The earliest version of Android was, “Android 1.0” and it was released on September 23, 2008.

What is ANR?
ANR is the short form for Application Not Responding; it is a dialogue that appears when an application has been unresponsive for a long period of time. If we run a big application on an OS in main thread we won’t be able to get responses back, so at this point, ANR is displayed.

Which database is used in Android?
Android system uses SQLite database; it is an open source, a lightweight relational database for mobile devices. It is inbuilt in the Android system by default, so one doesn’t need to perform any database setup or administration task.

Give some advantages of Android?

Listed below are the advantages of the Android operating system:
Ease of notification.
Ease of access to several applications
Modified ROMs can be flashed to android devices.
Multitasking is an added benefit.
Multiple language support.


What is activity?
The building block of the user interface is defined as an activity. Activity is a predefined class in Android all the applications which have the user interface (UI0 must inherit it. In other words, we can also define it as a Java code that supports a screen or UI. Activities are central to how a user navigates within an application while serving as an entry point for user’s interaction with an Android application.

What is Android Architecture?
The key components that constitute android architecture are given below:
Linux kernel
Libraries
Android framework
Android Applications

Define Intents.
The intent in an android system can be defined as a notification to the user or developer from within the Android-powered device that is used to alert him/her of a particular state that occurred so that the user can respond to it in a required manner.

What do you mean by AIDL?
AIDL: Android Interface Definition Language is used to handle interface requirements between a client and service so as to accommodate the same level of communication through IPC ( Inter Process Communication).The objects are broken down into primitives that android can understand.

What is Content Provider used for?
A content provider is part of an android system application which is used to provide a way to share data with other applications. In other words, it can be said that content provider manages the access to a repository of data.

What is the use of Android SDK?
Android SDK or Android Software development Kit is used for writing programs. SDK offers comprehensive tools for development of Android applications, some of which are; debugger, libraries, sample code, tutorials, etc. SDK also supports older android versions.

TOP 10 : MySQL Database Interview Questions For Experienced

By Dhananjay yadav → March 22, 2018
MySQL Database Interview Questions For Experienced

What are the storage engines used by MySQL?
Storage engines supported by MySQL are as follows:
  1. InnoDB
  2. MyISAM
  3. Memory
  4. CSV
  5. Merge
  6. Archive
  7. Federated
  8. Blackhole
Which one is the default storage Engine in MySQL?
The default engine is InnoDB.

What is a database engine?
Database Engine is the basic building blocks of storage systems , used by Database Management Systems to run CRUD (INSERT,SELECT,UPDATE,DELETE)instructions.

What is difference between InnoDB and MyISAM?
InnoDB is featured with ACID propety of transactions, but MyISAM does not support transaction. MyISAM supports FULLTEXT search index where as InnoDB does not.

What are HEAP tables in MySQL?
HEAP tables are the existing tables in memory.They also known as memory tables and use Indexes instead of BLOB and TEXt.

What are Stored Procedures in MySQL?
Stored Procedure is Batch of SQL statements and saved in database. It also accepts parameters and can be triggered explicitly. It improves the traffic control and gives a modular structure to implement maintainability.

CREATE PROCEDURE show_employee

AS

    SELECT FirstName, LastName

    FROM employee;

EXEC show_employee;

What is Trigger?
Auto executable sets of SQL statements stored in database are known as Triggers. They are fired when some event CRUD event occurs.When we do some CRUD operations on table the trigger linked with that table fires. Trigger is behaves like a stored procedure but it invoked automatically. It adds a layer of security in database.

What are differences between Trigger and Stored Procedure?

We can execute procedure explicitly whenever we would like , but trigger can only be invoked on an event fire.We can call a Procedure inside another Procedure but we can not invoke a trigger directly inside another trigger. We can use trigger for transaction purpose but we can not use procedure for transactions.

What are the CONSTRAINTs in MySQL?
MySQL CONSTRAINTs used to define the rules for data restrictions. MySQL provides various types of constraints as:
NOT NULL- does not allow NULL value
UNIQUE - does not allow duplicate entry in column
PRIMARY KEY - uniquely identify a rows in a table
FOREIGN KEY - Primary Key of another table is being as a reference in another table
CHECK - Check for the valid data to be saved in the database
DEFAULT - set the default value for the column, in case of no value passed to SQL statement.
We can declare MySQL CONSTRAINT at the time of table creation or we can alter table to apply CONSTRAINT.

What do you mean by index in a table?
MySQL Indexing is the indexing of data as keys to make the accessibility fast and easy. Rather than searching all over the data indexing allows to get directly to the indexed values. It Eliminates the unnecessary iteration because the indexes are stored in the form of B.Tree.