Skip to main content

AJAX, MYSQL, PHP

Interview Question and Answer for Ajax

1)  What is Javascript?

  Answer:- An object-oriented computer programming language commonly used to create interactive effects within web browsers.
  
2)  What is jQuery?

  Answer:- jQuery is a cross-platform JavaScript library designed to simplify the client-side scripting of HTML. jQuery is the most popular JavaScript library in use today, with installation on 65% of the top 10 million highest-trafficked sites on the Web. jQuery is free, open-source software licensed.
  
3)  Difference Between javascript and JQuery?

  Answer:- The main difference is: JavaScript is a programming language, while jQuery is a library.
  
4)  $("div").css("width","300px").add("p").css("background-color","blue");?

  Answer:- This code will make the div tag size with width - 300px, and add a paragraph tag with background-color blue.
  
5)  More efficient Lines? 
    document.get.ElementById("logo");
    OR
    $("#logo");

  Answer:- $("#logo"); is the more efficient because it uses the JQuery and it takes the less space.
  
6)  What does dollar Sign($) means in Jquery?

  Answer:- The $ is just a function. It is actually an alias for the function called jQuery, so your code can be written like this with the exact same results:
  jQuery('#text').click(function () { jQuery('#text').css('color','red');});
  
7)  Difference between ID selector and class selector in JQuery?

  Answer:- The $ is just a function. It is actually an alias for the function called jQuery, so your code can be written like this with the exact same results:
  
8)  How do you hide an div on a button click using jQuery?

  Answer:- $('#btn').onclick(funtction () {
           $("div").css("visibility","hidden");
  
9)  How do you set attribute using JQuery?

  Answer:- $("button").click(function(){
           $("#m3w").attr("href", "http://www.myweb.com/jQuery");
  
10) How to submit form without using submit button?

  Answer:- document.formname.submit();
  

Interview Question and Answer for MySql

1)  What is MySql?

  Answer:- With PHP, you can connect and manipulate databases.
           MySQL is the most popular database system used with PHP.
  
2)  List down 10 data types in MySql?

  Answer:- Int, Float, Varchar, enum, date, double, time, boolean, datetime
  
3)  Difference between primary key and unique key?

  Answer:- Each table must have at most ONE primary key but it can have multiple unique key. A primary key is used to uniquely identify a table row. A primary key cannot   be NULL since NULL is not a value.
  
4)  Difference between group by and order by?

  Answer:- Group By is use to group the same values and order by is use to give the output of sql query in Ascending and Descending order.
  
5)  Difference between float and double?

  Answer:- The Decimal, Double, and Float variable types are different in the way that they store the values. Precision is the main difference where float is a single precision (32 bit) floating point data type, double is a double precision (64 bit) floating point data type and decimal is a 128-bit floating point data type.
  
6)  What do you mean by % and _in the LIKE statement?

  Answer:- % specify that there may or may not be any character whereas _ specify that there must only one character.
  
7)  How can we get the number of rows affected by query?

  Answer:- mysql_affected_rows(mysql_query(“SELECT * FROM table_name”));
  
8)  What is the difference between mysql_fetch_array and mysql_fetch_object?

  Answer:- The mysql_fetch_array() function fetches a result row as an associative array, a numeric array, or both.
           The mysql_fetch_object() function returns the current row of a resultset, as an object.
  
9)  How to display top 50 rows?

  Answer:- By using LIMIT 0, 50;
  
10) How to display the structure of the table?

  Answer:- By using desc table_name;
  

Interview Question and Answer for PHP

1)  What is LAMP?

  Answer:- LAMP is an open source Web development platform that uses Linux as the operating system, Apache as the Web server, MySQL as the relational database management system and PHP as the object-oriented scripting language.
  
2)  What is the difference between client side language and server side language, give examples?

  Answer:- A Client side language is run on the client browser and the output is displayed on the client browser whereas server side language is run on the server and return back to the client browser with the information / errors.
  
3)  What is the use of header() function in php?

  Answer:- A header() function is used to redirect the pages.
  
4)  What are the different types of errors in php?

  Answer:- E_ERROR: A fatal error that causes script termination.
           E_WARNING: Run-time warning that does not cause script termination.
           E_PARSE: Compile time parse error.
           E_NOTICE: Run time notice caused due to error in code.
  
5)  Difference between GET and POST?

  Answer:- We can send 1024 bytes using GET method but POST method can transfer large amount of data and POST is the secure method than GET method.
  
6)  Difference between $_GET and $_POST?

  Answer:- $_GET is an array of variables passed to the current script via the URL parameters.
           $_POST is an array of variables passed to the current script via the HTTP POST method.
  
7)  What is $_REQUEST method?

  Answer:- $_REQUEST, by default, contains the contents of $_GET, $_POST and $_COOKIE.
  
8)  What is difference between required_once(), required(), include()?

  Answer:- require() includes and evaluates a specific file, while require_once() does that only if it has not been included before (on the same page). So, require_once() is recommended to use when you want to include a file where you have a lot of functions for example. This way you make sure you don't include the file more times and you will not get the "function re-declared" error.
  
9)  Explain the steps to connect with database?

  Answer:- //Step1
           $db = mysql_connect("localhost","username","password");
           if (!$db) {
            die("Database connection failed miserably: " . mysql_error());
           }
           //Step2
           $db_select = mysql_select_db("databasename",$db);
           if (!$db_select) {
            die("Database selection also failed miserably: " . mysql_error());
           }
  
10) Write down your own encryption algorithm?

  Answer:- <?php
              $str = "Hello";
              $str1 = "123abc";
              $strs = $str1.$str.$str1;
              echo $strs;
          ?>
  
11) How to get value of current session id?

  Answer:- by using session_id();
  
12) Explain some array functions?

  Answer:- is_array — Finds whether a variable is an array
           explode — Split a string by string
           implode — Join array elements with a string
           split — Split string into array by regular expression
           preg_split — Split string by a regular expression
           unset — Unset a given variable
  
13) What will be the output of following
             date(“Y-m-d H:i:s”);
             date(“y-M-D”);?

  Answer:- 2015-11-03 11:15:23
           15-Nov-Tue
  
14) How to get IP Address of user?

  Answer:- $_SERVER['REMOTE_ADDR']
  
15) Explain some string function?

  Answer:- echo Output one or more strings
           explode — Split a string by string
           fprintf — Write a formatted string to a stream
           ltrim — Strip whitespace (or other characters) from the beginning of a string
           rtrim — Strip whitespace (or other characters) from the end of a string
           trim — Strip whitespace (or other characters) from the beginning and end of a string
           str_replace — Replace all occurrences of the search string with the replacement string
           strlen — Get string length
           substr — Return part of a string
  
16) Explain isset and empty. Difference between these two?

  Answer:- isset(); checks if the variable is literally set, as in the variable actually points to a value something.empty(); checks if the value the variable points to contains anything.
  

Comments

Popular posts from this blog

Login and Registration Example in JSP with Session

Those who want to start with jsp and MySQL, this is an excellent example for themselves. Here you can learn how to insert data to MySQL using JSP. Also you can learn about session handling in jsp. 1 2 3 4 5 6 7 8 9 10 CREATE TABLE `members` (    `id` int (10) unsigned NOT NULL auto_increment,    `first_name` varchar (45) NOT NULL ,    `last_name` varchar (45) NOT NULL ,    `email` varchar (45) NOT NULL ,    `uname` varchar (45) NOT NULL ,    `pass` varchar (45) NOT NULL ,    `regdate` date NOT NULL ,    PRIMARY KEY   (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; index.jsp 1 2 3 4 5 6 ...

Timer funcitons in JavaScript: Reminder Script

Timers are used in web pages and we will discuss how to setup one and how to use one with an example. The function setTimeout() in function is used and here is its general syntax. mytime = setTimeout(expression, msec); mytime  is the identifier used to identify the current timeout function.  expression  is the statement that is to be executed after the specified time has ticked off.  msec  is the duration of time in milliseconds after which the expression will be executed.  You can see by using setTimeout function we can execute any function or object after a set of time. For example if msec is set 5000 then the expression will be executed after 5 seconds or 5000 milliseconds.  We will try one example where we will have four period buttons and each button will set a different time for another function to execute and display a alert button. We will call it as a reminder script and we will get one alert box based on the period button we click...

Binary Addition

/* File Name : BinAdd.java */    import java.util.*; public class BinAdd    {  public static String addBit(String a, String b, String c)  { String r=""; if(a.equals("1") && b.equals("0") || a.equals("0") && b.equals("1")) { if( c.equals("0")) r="1"; else { r="0"; c="1"; } } else if( a.equals("0") && b.equals("0") ) { if(c.equals("0")) r="0"; else r="1"; } else if( a.equals("1") && b.equals("1") ) { if(c.equals("0")){ r="0"; c="1"; } else { r="1"; c="1"; } } return c+r; }   public static String add(String a, String b)   { String r=""; int len=a.length(); String carry="0"; for(int i=len-1;i...

Real time changing Clock showing date and time

We can display a clock which will be showing the local time of the client computer by using JavaScript. Note that this time displayed is taken from user computer and not from the server.  We have seen in our  date object example how to display current date and time   where the current date and time is displayed once. Here we will try to display changing clock or real time change in date and time by using  setTimeout function . This setTimeout function we have used to trigger the time display function in a refresh rate of 1000 mill seconds ( 1 Sec ). This refresh rate can be changed to any other value. By changing the value to 5000 the clock will refresh and show the exact time once in every 5 seconds.  Here is the demo of this script and code is given below that.  Sat Apr 23 2016 08:27:22 GMT+0530 (IST)   Here is the code <html> <head> <title>(Type a title for your page here)</title> <script type="text/javascript...