Showing posts with label Question. Show all posts
Showing posts with label Question. Show all posts
JQuery interview questions and Answers
Posted by Raj
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?
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())
});
});
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())
});
});
What is an Object ?
Posted by Raj
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:
Behavior in OOPS: Every object has behavior.
Identity in OOPS: Each time an object is created the object identity is been defined.
Advantages of object oriented programming?
Posted by Raj
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.
What is UML?
Posted by Raj
Unified Modeling Language(UML)
UML stands for Unified Modeling Language.UML is used to manage large and complex systems.
With UML you can:
With UML you can:
- Manage project complexity.
- create database schema.
- Produce reports.
- Class Diagrams
- Package Diagrams
- Object Diagrams
- Use Case Diagrams
- Sequence Diagrams
- Collaboration Diagrams
- State chart Diagrams
- Activity Diagrams
- Component Diagrams
- Deployment Diagrams
What is Object Oriented Programming?
Posted by Raj
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:
What’s the special meaning of __sleep and __wakeup?
Posted by Raj
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();
}
}
?>
How do you call a constructor for a parent class?
Posted by Raj
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
}
}
Ternary conditional operator in PHP?
Posted by Raj
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;
?>
Will comparison of string and integer work in PHP?
Posted by Raj
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.
How do you define a constant?
Posted by Raj
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:
//define a constant
define("Test","Hello Rajesh Sharma! How are you today?");
echo constant("Test");
?>
How do you pass a variable by Reference?
Posted by Raj
Example:
<?php
function test (&$a)
{
$a++;
}
$b=10;
test ($b);
// $b is 11 here
?>
You can assign default value to pass-by-reference paramter.
<?php
function test(&$arg = 1) {
if ($arg == 1) {
echo $arg;
}
}
test();
?>
PHP Interpreter in php?
Posted by Raj
Ans:- PHP Interpreter treats numbers beginning with 0 as octal.
Difference between include and require in PHP?
Posted by Raj
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.
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.
What is the difference between $a and $$a?
Posted by Raj
$a is variable where as $$a is reference variable
like $a=Rajesh and $$a=Sharma so $Rajesh value is Sharma .
like $a=Rajesh and $$a=Sharma so $Rajesh value is Sharma .
Difference between varchar and nvarchar
Posted by Raj
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.
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.