Showing posts with label Question. Show all posts
Showing posts with label Question. Show all posts

JQuery interview questions and Answers

JQuery interview questions and Answers Advanced (Multiple Choice)- JQuery Quiz.

In this tutorial, I have selected advanced and basic Jquery Interview questions and answers with examples for freshers and 1 to 3 year experienced candidates.I have also included Objective Jquery ajax interview questions.


Advanced  JQuery interview questions and Answers:

What is Jquery?

jQuery is a JavaScript Library.

Which of the following is correct?

jQuery is a JavaScript Library
jQuery is a JSON Library

Answer :jQuery is a JavaScript Library

jQuery uses CSS selectors and XPath expressions to select elements?

False
True

Answer: True

Which sign does jQuery use as a shortcut for jQuery?

$ sign
% sign
? Sign

Answer: $ sign


Is jQuery a W3C standard?

Yes
No

Answer: NO


$("span"). What does it select?

All span elements
The first span element

Answer: All span elements

Is jQuery a library for client scripting or server scripting?

Client scripting
Server scripting

Answer: Client scripting

Is it possible to use jQuery together with AJAX?

Yes
No

Answer: Yes

The jQuery html() method works for both HTML and XML documents

True
False

Answer :False

jQuery code to set the background color of all span elements to blue?

$("span").style("background-color","blue");
$("span").manipulate("background-color","blue");
$("span").css("background-color","blue");
$("span").layout("background-color","blue");

Answer: $("span").css("background-color","blue");


$("span.intro"). What does it select?

The first span element with class="intro"
The first span element with id="intro"
All span elements with id="intro"
All span elements with class="intro"

Answer: All span elements with class="intro"

jQuery method to hide selected elements?

visible(false)
hidden()
display(none)
hide()

Answer: hide()

jQuery method to set one or more style properties for selected elements?

style()
css()
html()
 
Answer: css()

jQuery method is used to perform an asynchronous HTTP request?

jQuery.ajaxAsync()
jQuery.ajaxSetup()
jQuery.ajax()

Answer: jQuery.ajax()


What scripting language is jQuery written in?

VBScript
C++
JavaScript
C#

Answer: JavaScript

$("div#id1 .cl1"). What does it select?

The first element with id="cl1" inside any div element with class="id1"
All elements with class="cl1" inside the first div element with id="id1"
All div elements with id="id1" or class="cl1"

Answer: All elements with class="cl1" inside the first div element with id="id1"


Difference between onload() and document.ready() function used in jQuery?

  • We can add more than one document.ready() function in a page.
  • we can have only one onload function.
  • Document.ready() function is called as soon as DOM is loaded.
  • body.onload() function is called when everything (DOM, images..)gets loaded on the page.


JQuery Methods used to provide effects?

1. Show()
2. Hide()
3. Toggle()
4. FadeIn()
5. FadeOut()


What are the different type of selectors in Jquery?

1. CSS Selector
2. XPath Selector
3. Custom Selector

What does .size() method of jquery return ?

.size() method of jquery returns number of element in the object.


 How do you get the text value?

$("#textbox1").val();

 How do you check or uncheck a checkbox input or radio button?

1.$('#num1').attr('checked', true);// Check #num1

2.$('#num1').attr('checked', false);// Uncheck #num1

3.$("#num1").attr('checked', 'checked');// Check #num1

4.$("#num1").removeAttr('checked');// Uncheck #num1


Ajax Request in Jquery

$.ajax({
     url: 'test.php',
     success: function(response) {
        alert(response);
     },
     error: function(res) {
        alert(res.status);
     }
});


Explain the each() function.

$("#num").click(function(){
$("li").each(function(){
document.write($(this).text())
});
});



Bookmark and Share

What is an Object ?

what is Object in Object oriented programming.object is an instance of a class.An object is an entity that has attributes, behavior, and identity. Objects are members of a class.Object in OOP, PHP, Question, what is an object,com object,object,objective,object oriented,object oriented,object oriented programing,OOP

Object in Object oriented programming

object is an instance of a class.An object is an entity that has attributes, behavior, and identity. Objects are members of a class.
Objects are accessed, created or deleted during program run-time.


Declaration of an Object in OOPs
ClassName objectName=new ClassName();


Example:
Car objCar= new Car();

Attribute in OOPs: Attributes define the characteristics of a class. In Class Program attribute can be a string or it can be a integer. 
Behavior in OOPS:  Every object has behavior.
Identity in OOPS:  Each time an object is created the object identity is been defined.


Bookmark and Share

Advantages of object oriented programming?

Advantages of object oriented programming,Code Re-usability,Code extensibility,Maintainability,Modularity,Modifiability

Advantages of object oriented programming:

  • Code Re-usability(Polymorphism,Interfaces): In OOPs objects created in one program can be reused in different programs.
  • Code extensibility: for addding new features or modifying existing objects can be solved by introducing new objects.
  • Catch errors at compile time rather than at runtime.
  • Maintainability :objects can be maintained separately, so u can easily fix errors.
  • Imrove error handling:We can use exceptions to improve error handling.
  • Modularity: can create seperate Modules.
  • Modifiability:it is easy to make minor changes in some classes as Changes inside a class do not affect any other part of a program.


Bookmark and Share

What is UML?

UML stands for Unified Modeling Language.UML is used to manage large and complex systems

Unified Modeling Language(UML)

UML stands for Unified Modeling Language.UML is used to manage large and complex systems.


With UML you can:
  • Manage project complexity.
  • create database schema.
  • Produce reports.
Types of UML Diagrams:
  1. Class Diagrams
  2. Package Diagrams
  3. Object Diagrams
  4. Use Case Diagrams
  5. Sequence Diagrams
  6. Collaboration Diagrams
  7. State chart Diagrams
  8. Activity Diagrams
  9. Component Diagrams
  10. Deployment Diagrams


Bookmark and Share

What is Object Oriented Programming?

Introduction to Object-Oriented Programming Using PHP.This page will describes the term `object-oriented programming`.let's start with few basic concepts before you can begin writing any code.<br /> Object-oriented programming is a method of programming based on a hierarchy of classes, and well-defined objects

Object Oriented Programming

Introduction to Object-Oriented Programming Using PHP.This page  will describes the term `object-oriented programming`.let's start with few basic concepts before you can begin writing any code.
Object-oriented programming is a method of programming based on a hierarchy of classes, and well-defined objects.


Brief overview of object-oriented concepts and terminology:


Bookmark and Share

What’s the special meaning of __sleep and __wakeup?

__sleep,PHP, Question, php5 magic methods,__sleep and __wakeup,What’s the special meaniacng of __sleep and __wakeup,__sleep and __wakeup in PHP
What’s the special meaning of __sleep and __wakeup?


__sleep returns the array of all the variables than need to be saved.
 __wakeup retrieves them.


__sleep() and __wakeup() run prior to serialize() and unserialize() respectively.


Example:
<?php
class DBConn
{
    protected $conn;
    private $host, $username, $password, $db;
    
    public function __construct($host, $username, $password, $db)
    {
        $this->host = $host;
        $this->username = $username;
        $this->password = $password;
        $this->db = $db;
        $this->connect();
    }
    
    private function connect()
    {
        $this->conn = mysql_connect($this->host, $this->username, $this->password);
        mysql_select_db($this->db, $this->conn);
    }
    
    public function __sleep()
    {
        return array('host', 'username', 'password', 'db');
    }
    
    public function __wakeup()
    {
        $this->connect();
    }
}
?>


Bookmark and Share

How do you call a constructor for a parent class?

base class,constructor,call,parent class,PHP, Question, call constructor from parent,PHP: Calling Parent Class Constructors,class Parent
How do you call a constructor for a parent class? 


parent::constructor($value)


Example:



class parentClass
{
     function __construct()
   {
    }
}


class chClass extends parentClass
{
   function __construct()
   {
      parent::__construct(); //call a constructor for a parent class
       }
}






Bookmark and Share

Ternary conditional operator in PHP?

Ternary conditional operator, PHP, Question, conditional operator,ternary operator,explode php,php implode
Ternary conditional operator:
Expression preceding the ? is evaluated, if it’s true, then the expression preceding  the : is executed, otherwise, the expression following : is executed.


Syntax:
Condition ? value if true :value if false;


Example:
<?php
$id = isset($_POST['name']) ?  $_POST['name'] : false;
?>


Bookmark and Share

Will comparison of string and integer work in PHP?

PHP, PHP: Comparison Operators - Manual, Question
Yes you can compare string and integer in PHP  as  internally PHP will cast everything to the integer type, so numbers 100 and 100 will be compared.


Bookmark and Share

How do you define a constant?

PHP, PHP constant() Function, PHP: Constant - Manual, PHP: Constants - Manual, PHP: define - Manual, Question, how do you define a constant
In this section, I will explain how to define a constant in PHP.


define("Test","Hello Rajesh Sharma! How are you today?");

The constant() function returns the value of a constant.
Syntax:
constant(constant);

Example:

<?php
//define a constant
define("Test","Hello Rajesh Sharma! How are you today?");


echo constant("Test");
?>




Bookmark and Share

How do you pass a variable by Reference?

You can pass a variable by reference to a function.
Example:

<?php
function test (&$a)
{
    $a++;
}

$b=10;
test ($b);
// $b is 11 here
?>

Note: you can't pass NULL to a function by reference, unless it's as a default value.



You can assign default value to pass-by-reference paramter.


<?php 
function test(&$arg = 1) { 
    if ($arg == 1) { 
       echo  $arg; 
    } 

test(); 
?> 



Bookmark and Share

PHP Interpreter in php?

I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, what’s the problem?


Ans:- PHP Interpreter treats numbers beginning with 0 as octal.

















Bookmark and Share

Difference between include and require in PHP?

What’s the difference between include and require in PHP?

require(): If the file is not found by require(), it will cause a fatal error and halt the execution of the script.
include(): If the file is not found by include(), a warning will be issued, but execution will continue.



Bookmark and Share

What is the difference between $a and $$a?

$a is variable where as $$a is reference variable 
like $a=Rajesh and $$a=Sharma so $Rajesh  value is  Sharma .


Bookmark and Share

Difference between varchar and nvarchar

varchar, nvarchar, what is difference between varchar and nvarchar, varchar and nvarchar, nvarchar max, difference in sql, nvarchar in sql, varchar nvarchar difference, nvarchar sql, difference sql, nvarchar data type, nvarchar unicode, nchar varchar, nchar char, nvarchar nchar, varchar vs nchar, sql differences, differences sql, sql nvarchar max
Difference between varchar and nvarchar:


The data type Varchar and NVarchar both will used to store the string values.
Varchar - Non-Unicode Data (1 Byte)
NVarchar - Unicode Data (2 Byte)

Storage Size :
Varchar - Actual Length (in bytes)
NVarchar - 2 times Actual Length (in bytes).



VARCHAR is an abbreviation for variable-length character string. It's a string of text characters that can be as large as the page size for the database table holding the column in question.

The "N" in NVARCHAR means uNicode. Essentially, NVARCHAR is nothing more than a VARCHAR that supports two-byte characters. The most common use for this sort of thing is to store character data that is a mixture of English and non-English symbols

The key difference between the two data types is how they're stored. VARCHAR is stored as regular 8-bit data. 

But NVARCHAR strings are stored in the database as UTF-16 — 16 bits or two bytes per character, 

UniCode:
Using Unicode data types, a column can store any character defined by the Unicode Standard, which includes all of the characters defined in the various character sets. Unicode data types take twice as much storage space as non-Unicode data types.
Unicode data is stored using the nchar, nvarchar, and ntext data types in SQL Server.





Bookmark and Share