Saturday, October 9, 2010

Difference between abstract class and interface


ABSTRACT CLASS:
1.An object of abstract class cannot be created as it can contain unimplemented functions.
2)An Abstract class can also contain concrete methods(Non-Abstract).
3)In derived class we can use abstract method by using override keyword.
4) we can't use multiple inheritance in abstract class.
5) Absrtact class can be extended by only one class; Interface can be implemented by more than one class;ie. class can inherit only one abstract class.

6)Abstract classes can inherit interfaces while interfaces cannot inherit abstract classes but class can implement more than one interface.
7) The members of the interface are public with no implementation. Abstract classes can have protected ,static methods, etc.

8)An abstract class can contain fields, constructors, or destructors and implement properties. An interface can not contain fields, constructors, or destructors and it has abstract method,property's signature but no implementation.

Sunday, October 3, 2010

Difference between onload and document.ready in JQuery


What is the difference between using $(document).ready function and window.onload() function ?
Ans: The onload handler for the window instance is used for executing statements after the entire page is fully loaded. Below is an example of syntax of window.onload function
window.onload = function() {
$("table tr:nth-child(even)").addClass("even");
};
Here the browser executes the onload code after the DOM tree is created and after all images and other external resources are fully loaded and after  the page is displayed in the browser window. As a result, visitors can experience a delay between the time that they first see the page and the time that the onload script is executed.
The $(document).ready function waits only until the document structure is fully parsed and the browser has converted the html into its DOM tree form before executing the script to apply the rich behaviors . that is it triggers the execution of code once the DOM tree, but not external image resources, has loaded. An example of defining such code is as below:
$(document).ready(function() {
$("table tr:nth-child(even)").addClass("test");
});

Here First, we wrap the document instance with the jQuery() function, and then we
apply the ready() method, passing a function to be executed when the document
is ready to be manipulated.