Pages

Friday, September 2, 2011

Jquery Interview Questions


Top jQuery interview questions and answers are below
Questions : 1 What is jQuery ?
Answers : 1 It's very simple but most valuable Question on jQuery means jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, animating, event handling, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. Jquery is build library for javascript no need to write your own functions or script jquery all ready done for you
Questions : 2 How you will use Jquery means requirement needed for using jquery
Answers : 2

Nothing more need to do just olny download jquery library(.js file) from any of the jquery site Download jquery and just linked with your html pages like all other javascript file
like below :
< script src="jquery.js" language="javascript" type="text/javascript">
Questions : 3 what the use of $ symbol in Jquery
Answers : 3

$ Symbol is just replacement of jquery means at the place of $ you may use jquery hence $ symbol is used for indication that this line used for jquery
Questions : 4 How do you select an item using css class or ID and get the value by use of jquery
Answers : 4 If an element of html like < div> , < p> or any tag have ID MyId and class used MyClass then we select the element by below jquery code

$('#MyId') for ID and for classs $('.MyClass') and for value

var myValue = $('#MyId').val(); // get the value in var Myvalue by id
Or for set the value in selected item

$('#MyId').val("print me"); // set the value of a form input

JQuery Interview Questions


Q.What is jQuery?
A.jQuery is a JavaScript library that simplifies JavaScript and AJAX programming. JavaScript is used to add interactivity and dynamic content to web pages. AJAX (Asynchronous JavaScript and XML) is used for handling external data asynchronously through JavaScript, without refreshing the whole page.
jQuery emphasizes the interaction between JavaScript and HTML. jQuery contains all the common DOM, event, effects, and Ajax functions in a single JavaScript file.The jQuery file needs to be included in the file which is going to use the jQuery functionality.jQuery provides a new class called jQuery without extending the built-in JavScript classes which acts as a wrapper around objects for providing them the extended operations.jQuery is a lightweight JavaScript library that emphasizes interaction between JavaScript and HTML.

Q.What are the advantages of JQuery?
A.Advantages of jQuery
The advantages of using jQuery are:
1.JavaScript enhancement without the overhead of learning new syntax
2.Ability to keep the code simple, clear, readable and reusable
3.Eradication of the requirement of writing repetitious and complex loops and DOM scripting library calls

Q.Explain the features of jQuery.
A.Features of jQuery are :
1.Effects and animations
2.Ajax
3.Extensibility

Explain the concepts of "$ function" in jQuery with an example.
A.The type of a function is "function".There are a lot of anonymous functions is jquery.

$(document).ready(function() {});
$("a").click(function() {});

$.ajax({
url: "someurl.php",
success: function() {}
});

Q.Why is jQuery better than javascript?
A.jQuery is great library for developing ajax based application.It helps the programmers to keep code simple and concise and reusable.jQuery library simplifies the process of traversal of HTML DOM tree.jQuery can also handle events, perform animation, and add the ajax support in web applications.

Q.When can you use jQuery?
A.JQuery can be used to
1.apply CSS
2.call functions on events
3.traverse the documents
4.manipulation purpose and
5.to add effects too.

Q.Explain the concepts and capabilities of Aspect-Oriented Programming, AOP.
A.AOP concepts:
1.Aspect: A cross cutting modularization across multiple objects. Aspects are implemented by using regular classes.
2.Join point: A point while executing a program, such as running an exception or a program. In certain frameworks , a method is always treated as a join point.
3.Advice: Advice is an action that is taken by an aspect at a certain joint point. “around”,”before”,”after” are different types of advice.
4.Pointcut: A condition / predicate that matches join points. An advice is associated with a point cut expression. It is run at any joint point matched by the point cut.
5.Target object: An object that is advised by one or more aspects.
6.AOP proxy: To implement the aspect contracts or advice methods, AOP proxy object is created.
7.Weaving: Applications or objects are linked by aspects by weaving process, for creation of an advised object. This process can be performed at runtime.

Q.What is Aspect in AOP?
A.Aspect is a program segment that cross-cuts the core concerns of the application. For instance, after logging, different functional concerns of different modules are to be performed. So, the logging code can cross-cut these modules, though the aspect of logging is separate.

Q.AOP approach addresses Crosscutting concerns. Explain
A.Examples of these “cross-cutting concerns” can be:Security, Transactions,Logging

1.Security: The security implementation, specifically authorization, the use of a popular and flexible security framework can be used in enterprise applications, namely, Acegi. Acegi security simplifies implementing the authorization in applictions in a flexible manner.

2.Transactions: Transactions are handled in a declarative and programmatic faction. This approach is implemented in some of the frameworks for enterprise applications. Declaring an appropriate data source, transaction manager is to be configured first.The transactionality advice and the corresponding transactinality characteristics like isolation, timeout etc., is to be performed later.

3.Logging: Among the concerns, the Logging is the easiest concern to be implemented. To implement, a simple java class can be used. Logging includes specifying the pointcut expression and the aspect's advice type.

Q.The components of AOP are advices/interceptors, introductions, metadata, and pointcuts. Explain them
A.
1.Advice / Interceptor: An object that intercept the invocation of a method before its execution. Interceptor embodies the behavior to add or remove or replace the functionality of infrastructure. Perfect pluggability without changes need for business logic is provided by Interceptor.

2.Introductions: Introductions adds states and functionality to the existisng objects.

3.Pointcuts: Pointcuts allows to define the loction of interceptors and introductions are to applied.

4.Metadata: Metadata provide information about class and runtime system hints for treating the classes. For example, AOP logging , monitoring of the code without instrumenting with the code.

Q.Explain AOP vs OOPs
A.AOP :
1.Addresses cross cutting concerns
2.Code creation is clear.
3.Reusability of code is at a great extent.
4.Properly separates business logic into reusable code.
5.Modularization is based o Processes / Functionalities.

OOP:
1.
2.Functinality is within a class.
3.Code modularization is into real world objects.
4.Implementation is forced by the developer.
5.Modularity is based on real world objects.

Q.Explains similarities between AOP and OOPs.
A.Both extends and alter the behaviour of code.Adding new behaviours or replacing completely the original behaviour.The following are the advantages of AOP:
1.Code layering
2.Cross-cutting concerns
3.Code adjusting

Q.What is a software design pattern?
A.A reusable software design solution in general for the problems that are recurrently occuring. Design pattern is not a solution but a description for how to solve a problem in different situations. OOP design patterns establishes the relationships between classes or objects. Design patterns are specifically dealt with problem solving at the software design level.

Q.What is an analysis pattern?
A.It is a software pattern which is not related to a language. It is related to a business domain like health care, telecom. The visiting activity of a patient in the health care domain would be subject to a number of patterns.

Q.What are the differences between analysis patterns and design patterns?
A.Analysis pattern are targeted for domain architecture, where as design pattern are targeted for implementation mechanism for some of the aspects of the domain. Analysis patterns are functional oriented and of high level.

Q.What is Singleton pattern?
A.Singleton pattern is one of the design patterns that is utilized for restricting instantiation of a class to one or few specific objects. This facility is particularly useful when the system requires to coordinate the actions with exactly one object.

Q.How do you write a Thread-Safe Singleton?
A.The following are the steps to write a thread-safe singleton:
1.Declare a Boolean variable, ‘instantiated’, to know the status of instantiation of a class, an object of Object class and a variable of the same class with initial value as null.
2.Write a private constructor of this class
3.Override getInstance() method. Check the Boolean state of the instance variable ‘instantiated’. If it is false, write a ‘synchronized’ block and test for the current class instance variable. If it is null create an object of the current class and assign it to the instance variable.
The following code illustrates this :

public class SampleSingleton {
private static boolean initialized = false;
private static Object obj = new Object();
private static SampleSingleton instance = null;
private SampleSingleton() {
// construct the singleton instance
}
public static SampleSingleton getInstance() {
if (!initialized) {
synchronized(obj) {
if (instance == null) {
instance = new SampleSingleton();
initialized = true;
}
}
}
return instance;
}
}

Q.What is the Reactor pattern?
A.The Reactor pattern is an architectural pattern that allows demultiplexing of event-driven applications and dispatch service requests which are delivered by one or more application clients to an application.The reactor pattern is used in a manner that is synchronous. So that the delegated callback event takes a while for completing the running problems with scalability.

Q.What are Process Patterns?
A.Methods, best practices, techniques for developing an Object-Oriented software comprises a process pattern.

Q.What are Collaboration Patterns?
A.Repeatable techniques which are utilized by people of different teams for helping them work together. The really have nothing to do with object-oriented development. The fact is that these patterns can support with requirement gathering .

Q.What is session facade?
A.Session Façade is one of the design pattern. It is utilized in developing enterprise applications frequently. Session Façade is implemented as a higher level component like Session in EJB, and has all iterations between low level components like Entity in EJB. After that, it provides an interface that functions an application or part of it. Then it decouples the lower level components by simplifying the design.

Q.What are Anti-Patterns?
A.A design pattern which obviously appears, but is an ineffective or far from optimal in practice. There must be atleast two key elements for formally distinguishing an actual anti-pattern from a single bad idea, bad practice or bad habit.

Q.How do I document a design pattern?
A.The following are the major points for describing a pattern.
1.Short and meaningful name for the pattern is to be selected.
2.Problem description and goals and constraints that may occur in that context is to be identified.
3.The participating classes and objects in the design pattern and their structure, responsibilities and their collaborations are to be decided. An abstract description is applied in many different situations are provided by the solution.
4.Identify the uses in the real systems and its efficiency.

Q.How to use jQuery?
A.jQuery can be easily used with other libraries so it should work out of the box with simple and complex JavaScript and Ajax..

Q.How to use jQuery library in our ASP.Net project?
A.Download the latest jQuery library from jQuery.com and include the reference to the jQuery library file in our ASPX page.





$(document).ready(function() {

alert('test');

});



Q. With jQuery UI 1.7 being released in the last few days, what do you see as the key parts of jQuery UI 1.7? What are you most proud of out of that release?
A.The one thing I’m most proud of is that our framework has matured so much since 1.5. We have taken great care to unify our API, fix hundreds of compatibility and behavior issues, and now we truly have a foundation to build upon without needing to rewrite the core functionality again and again. This will allow us to push our features in the next releases in literally no time.

Q.What were the biggest challenges of getting the 1.7 release out there?
A.Our test coverage is still incomplete, and with every fixed bug, we introduced 2 others, which made the arrival at a stable level extremely difficult. Every week, there were some 50-100 bugs entered in the bugtracker, and there was literally no end. Luckily, we were able to triage the bugs to critical and blockers and solve these in time for a release. You have to have a lot of guts to push out a release that’s still imperfect - but an imperfect release is better than one that gets delayed for months. You can always roll out 1.7.1.

Q.Jumping off of jQuery UI for a second, Do you “release early, release often” with all of your projects? What are your thoughts on that strategy?
A.Speaking for myself, I often release too early. That has been a problem in the past, when we released versions as stable that weren’t, for instance. So it’s important to find a combination of both - a stable release must be stable, while development cannot be halted or blocked through stubborn processes. A labs section is great in that way - it allows developers to contribute freely and plan on an open canvas, with early preview releases, and the work can later be merged back.

Q.Have any of your startup projects failed dismally - if so, why and how did you learn from them?
A.A lot of my side projects failed, as a matter of fact, while others succeeded. Usually, the reason why some project fails is not a technical one, but the fact that one didn’t build meta data around it. That means a dedicated site, documentation, instructions.

Q.Mac, Windows or Linux? Why do you love this platform while using jQuery?
A.I switched to Mac hardware around a year ago and I’m totally in love with it. All components work together nicely, and so far, I never had to return my Macbook Pro to the Apple Store because of an issue. However, I’m still using Windows through Parallels because OSX, while visually nice and stable, has fundamental usability flaws.One of these flaws is the Finder. I recently worked on the jQuery UI Selectables in the labs version, and once again saw that the Finder had great flaws when it comes down to selection. For instance, if you select multiple items and click on one of them, the multiple selection isn’t cleared. Also, my tools that I love for windows simply don’t have an alternative yet .


Q.What are your tools of choice to get the jQuery job done?
A.For editing files, I love the e texteditor (yep, the name is “e”). It basically started as a textmate clone for windows, but since then grew into something much greater. One of the features I can’t live without now is there great multiple selection support. Hold down CTRL, select a couple words through double clicking and then type over all of them.On a sidenote, on one of my talks in Japan the audience asked why I’m so insane to use a Textmate clone through an emulated Windows on OSX - I showed them this exact feature, and they were all amazed.

Q.Back onto jQuery UI… Can you see jQuery UI making more of an impression in the future, lead by the current successes of jQuery?
A.jQuery, other than jQuery UI, can be useful almost everytime. jQuery UI gives you a specific set of user interface widgets and behaviours, and many people think of it as loosing a kind of freedom. On the other hand, there’s definitely some connection - if you’re using Prototype already, and you’re looking for an UI framework, your choice is most often script.aculo.us. If you’re using jQuery, why not use the official side project?

Q.Whats next on the hitlist with jQuery UI?
A.There’s a lot of movement right now. We finally pushed out 1.7 3 days ago, which we believe is a solid foundation for everything that’s coming in in the next couple of months. While 1.7 was a stability and foundation release, the next releases will concentrate around features, so expect to see many more components soon. Some examples are the colorpicker, menu, grid, tooltip and tree widgets.

Q.Is it too early to discuss jQuery UI 1.8?
A.There’s a lot on our list for the year. Filament Group did a great job to start a list of all widgets they could imagine being part of jQuery UI, which can be found and discussed in the jQuery UI planning wiki at http://wiki.jqueryui.com. There’s no definite roadmap for 1.8 yet, but some components are likely to make it into the next release. For instance, widgets that are already being worked on (grid, menu), as well as widgets that we had to kick out of 1.6/1.7 because they weren’t stable enough (spinner, colorpicker, autocomplete). It will be a huge feature release!

Q.If you could give one tip to any new budding jQuery UI developers, what would it be?
A. For jQuery UI, we’re trying to take the same path than jQuery, and people that are restricted to thinking in classical OOP patterns will have a problem. If you think about it freely and give the functional, event-driven and progressive approach a try, you’ll find yourself getting the work done with jQuery UI in a fraction of the time needed than with other frameworks.

Q.what is jQuery connect?
A.It is a jquery plugin which enables us to connect a function to another function. It is like assigning a handler for another function. This situation happens when you are using any javascript plugins and you want to execute some function when ever some function is executed from the plugin. This we can solve using jquery connect function.

Q.Different ways of using $.connect function in jQuery?
A.The syntax of connect function is
$.connect(sourceObj/*object*/, sourceFunc/*string*/, callObj/*object*/, callFunc/*string or Func*/)
sourceObj(optional) is the object of the source function to which we want to connect
sourceFunc is the function name to which we want to connect
callObj(optional) is the object which we want to use for the handler function
callFunc is the function that we want to execute when sourceFunc is executed.

Here sourceObj, callObj are optional for the global functions.
suppose if your sourceFunc is global function then no need to pass the sourceObj or you can use null or self
suppose if your callObj is global function then no need to pass the callObj or you can use null or self

ex:
// fun1, fun2 are global functions
1. $.connect('fun1',fun2)
2. $.connect(null,'fun1',fun2)
3. $.connect(self,'fun1',fun2)
4. $.connect('fun1',null,fun2)
5. $.connect('fun1',self,fun2)
6. $.connect(self,'fun1',null,fun2)

Q.Explain the features of jQuery?
A.Features of jQuery are :

1.Effects and animations
2.Ajax
3.Extensibility
4.DOM element selections functions
5.Events
6.CSS manipulation
7.Utilities - such as browser version and the each function.
8.avaScript Plugins
9.DOM traversal and modification

Q.Explain the concepts of "$ function" in jQuery with an example?
A.The type of a function is "function".
There are a lot of anonymous functions is jquery.

$(document).ready(function() {});
$("a").click(function() {});

$.ajax({
url: "someurl.php",
success: function() {}
});

Q.Why is jQuery better than JavaScript?
A.
1.JQuery is great library for developing ajax based application.
2.It helps the programmers to keep code simple and concise and reusable.
3.jQuery library simplifies the process of traversal of HTML DOM tree.
4.jQuery can also handle events, perform animation, and add the Ajax support in web applications.


No comments:

Post a Comment