Showing posts with label JavaScript. Show all posts
Showing posts with label JavaScript. Show all posts

February 15, 2021

Top 20 AJAX Interview Questions and Answers

 

Ques. 1): Is AJAX a programming language?

Answer: 

No, it is not. AJAX is an innovative technique designed for the purpose of creating modern day rapidly performing web applications in order to make the world of internet faster and more conducive to users. Importantly, AJAX primarily makes use of asynchronous data transfer between the web server and the browser.

AngularJS Interview Questions and Answers

Ques. 2): So, what do you think are the eventual objectives of AJAX in the first place?

Answer: 

AJAX has many potential objectives. First and foremost, it is used to mitigate the intensity of core network load, not to mention building a highly interactive user interface. Also, a reduced web server hit is one of the major goals of using AJAX. Additionally, platform and architecture neutrality continues to be the rudimentary aspects of AJAX. Moreover, it is also used for the purpose of both synchronous and asynchronous communication.

JavaScript Interview Questions and Answers

Ques. 3): Is Ajax Just Another Name For Xmlhttprequest?

Answer: 

No. XMLHttpRequest is only part of the Ajax equation. XMLHttpRequest is the technical component that makes the asynchronous server communication possible; Ajax is our name for the overall approach described in the article, which relies not only on XMLHttpRequest, but on CSS, DOM, and other technologies.

Node.js Interview Questions and Answers

Ques. 4): Why Does Html_ajax Hang on Some Server Installs?

Answer: 

If you run into an HTML_AJAX problem only on some servers, chances are your running into a problem with output compression. If the output compression is handled in the PHP config we detect that and do the right thing, but if its done from an apache extension we have no way of knowing its going to compress the body. Some times setting HTML_AJAX::sendContentLength to false fixes the problem, but in other cases you'll need to disabled the extension for the AJAX pages.

I've also seen problems caused by debugging extensions like XDebug, disabling the extension on the server page usually fixes that. Questions dealing with Using HTML_AJAX, and general JavaScript development

JQuery Interview Questions and Answers

Ques. 5): Are Ajax Applications Easier To Develop Than Traditional Web Applications?

Answer: 

Not necessarily. Ajax applications inevitably involve running complex JavaScript code on the client. Making that complex code efficient and bug-free is not a task to be taken lightly, and better development tools and frameworks will be needed to help us meet that challenge.

Advance Java interview Questions and Answers

Ques. 6): What is the difference between proxied and proxyless calls in AJAX?

Answer: 

Proxied calls are made through stub objects which can be called from PHP classes on the JavaScript side in AJAX.

Proxyless calls are made using utility JavaScript functions like HTML_AJAX.replace() and HTML_AJAX.append() in AJAX.

 

Ques. 7): What are the pre-requisites to execute AJAX applications on a server?

Answer: 

AJAX is a built-in functionality of .NET Framework 4.0 and AJAX application can be executed by just installing Microsoft Visual Studio 2010. To use extenders in your applications, you are required to install AJAX Control Toolkit and copy the AjaxControlToolkit.dll file to the Bin directory of your application.

 

Ques. 8): One of the demerits of AJAX is the redundant flow of requests. How can we hope to tackle simultaneous requests in AJAX?

Answer: 

To tackle concurrent requests, the respective Java script functions need to be written. Having written the functions, the call back function can be applied as a parameter in order to tackle simultaneous requests. The concerned parameters are then passed to what is known as the Ajax Interaction object to tackle the concurrency of incoming requests.

 

Ques: 9): What do you understand by the script manager?

Answer: 

Chiefly, the Script Manager acts as a perfunctory mediator. It is essentially important for the management of the client-side script of AJAX. It is important to note that any page that uses AJAX has a Script Manager in order to enable the application of AJAX libraries.

 

Ques: 10): What Browsers Does Html_ajax Work With?

Answer: 

We don't have a list right now, but most of the API is stable as of 0.3.0, all the examples that ship with HTML_AJAX have been verified to work with

1.    Firefox 1.0+

2.    Internet Explorer 5.5+ (5.0 should work but it hasn't been tested)

Most things work with

1.    Safari 2+

2.    Opera 8.5+ of 0.3.0. There should be no major changes at this point, though there will be lots of new additions.

 

Ques: 11): How many types of triggers are present in update panel?

Answer: 

There are two types of triggers used in update panel:

•      PostBackTrigger – This works as full postback and it cannot work asynchronously

•      AsyncPostBackTrigger – Partial post back asynchronously

 

Ques: 12): What are the disadvantages of Ajax?

Answer: 

Following are the disadvantages of Ajax:

1.    AJAX is dependent on Javascript. If there is some Javascript problem with the browser or in the OS, Ajax will not support

2.    Ajax can be problematic in Search engines as it uses Javascript for most of its parts.

3.    Source code written in AJAX is easily human readable. There will be some security issues in Ajax.

4.    Debugging is difficult

5.    Increases size of the requests

6.    Slow and unreliable network connection.

7.    Problem with browser back button when using AJAX enabled pages.

 

Ques. 13): What is the difference between RegisterClientScriptBlock, RegisterClientScriptInclude and RegisterClientScriptResource?

Answer: 

Following are the functions:

•      RegisterClientScriptBlock – The script is specified as a string parameter.

•      RegisterClientScriptInclude – By setting the source attribute to a URL that point to a script file.

•      RegisterClientScriptResource – specifies Resource name in an assembly. The source attribute is automatically populated with a URL by a call to an HTTP handler that retrieves the named script from the assembly.

 

Ques. 14): What are the properties of XMLHttpRequest?

Answer: 

The important properties of the XMLHttpRequest object are given below.

•    onReadyStateChange - It is called whenever readystate attribute changes.

•    readyState - It represents the state of the request.

•    responseText - It returns response as text.

•    responseXML - It returns response as XML.

•    status - It returns the status number of a request.

•    statusText - It returns the details of status.

 

Ques. 15): What are the different ready states of a request in AJAX?

Answer: 

There are 5 ready states of a request in AJAX.

•    0 means UNOPENED

•    1 means OPENED

•    2 means HEADERS_RECEIVED

•    3 means LOADING

•    4 means DONE

 

Ques. 16): Won't My Server-side Framework Provide Me With Ajax?

Answer: 

You may be benefiting from AJAX already. Many existing Java based frameworks already have some level of AJAX interactions and new frameworks and component libraries are being developed to provide better AJAX support. I won't list all the Java frameworks that use AJAX here, out of fear of missing someone, but you can find a good list at www.ajaxpatterns.org/Java_Ajax_Frameworks.

If you have not chosen a framework yet it is recommended you consider using JavaServer Faces or a JavaServer Faces based framework. JavaServer Faces components can be created and used to abstract many of the details of generating JavaScript, AJAX interactions, and DHTML processing and thus enable simple AJAX used by JSF application developer and as plug-ins in JSF compatible IDE's, such as Sun Java Studio Creator.

 

Ques. 17): Is Adaptive Path Selling Ajax Components Or Trademarking The Name? Where Can I Download It?

Answer: 

Ajax isn’t something you can download. It’s an approach — a way of thinking about the architecture of web applications using certain technologies. Neither the Ajax name nor the approach is proprietary to Adaptive Path.

 

Ques. 18): Some Of The Google Examples You Cite Don't Use Xml At All. Do I Have To Use Xml And/or Xslt In An Ajax Application?

Answer: 

No. XML is the most fully-developed means of getting data in and out of an Ajax client, but there’s no reason you couldn’t accomplish the same effects using a technology like JavaScript Object Notation or any similar means of structuring data for interchange.

 

Ques. 19): Are There Any Security Issues With Ajax?

Answer: 

JavaScript is in plain view to the user with by selecting view source of the page. JavaScript cannot access the local file system without the user's permission. An AJAX interaction can only be made with the servers-side component from which the page was loaded. A proxy pattern could be used for AJAX interactions with external services.

You need to be careful not to expose your application model in such as way that your server-side components are at risk if a nefarious user to reverse engineer your application. As with any other web application, consider using HTTPS to secure the connection when confidential information is being exchanged.

 

Ques. 20): When Should I Use A Java Applet Instead Of Ajax?

Answer:

•    Applets provide features like custom data streaming, graphic manipulation, threading, and advanced GUIs which AJAX cannot.

•    However, with the help of DHTML, the functionalities of AJAX can be extended further.

•    AJAX requires that the browser be DHTML and AJAX capable.

•    AJAX-based functionality does need to take browser differences into consideration due to which using a JavaScript library such as Dojo which abstracts browser differences is recommended.

•    AJAX/DHTML works well for applications where the latest browsers are used.

 

 

February 10, 2021

Top 20 JavaScript Interview Questions and Answers

 

Ques. 1): What is JavaScript?

Answer: 

JavaScript is different from Java language. It is a scripting language. It is object-based, lightweight, cross-platform translated language. It is widely used for client-side validation. The JavaScript Translator, which is embedded in the browser, is responsible for translating the JavaScript code for the web browser.

AngularJS Interview Questions and Answers

Ques. 2): What are the differences between Java and JavaScript?

Answer: 

JavaScript is a coded program that can be introduced to HTML pages. In contrast, Java is a complete programming language. These two languages are not at all inter-dependent and are designed for the different intent. Java is an object - oriented programming (OOPS) or structured programming language like C++ or C whereas JavaScript is a client-side scripting language.

AJAX interview Questions and Answers

Ques. 3): What are the main advantages of JavaScript?

Answer: 

The main advantages of using JavaScript are as follows:

  • Less server interaction − You can validate user input before sending the page off to the server. This saves server traffic, which means less load on your server.
  • Immediate feedback to the visitors − They don’t have to wait for a page reload to see if they have forgotten to enter something.
  • Increased interactivity − You can create interfaces that react when the user hovers over them with a mouse or activates them via the keyboard.
  • Richer interfaces − You can use JavaScript to include such items as drag-and-drop components and sliders to give a Rich Interface to your site visitors.

Node.js Interview Questions and Answers

Ques. 4): Which is faster, JavaScript or an ASP script?

Answer: 

JavaScript is a client-side language and thus it does not need the assistance of the web server to execute. On the other hand, ASP is a server-side language and hence is always slower than JavaScript. Javascript now is also a server-side language (nodejs). So the JavaScript is faster.

JQuery Interview Questions and Answers

Ques. 5): What is the use of history object?

Answer: 

The history object of a browser can be used to switch to history pages such as back and forward from the current page or another page. There are three methods of history object.

1.         history.back() - It loads the previous page.

2.         history.forward() - It loads the next page.

3.         history.go(number) - The number may be positive for forward, negative for backward. It loads the given page number.

Advance Java interview Questions and Answers

Ques. 6): What are global variables? How are these variables declared and what are the problems associated with using them?

Answer: 

Global variables are those that are available throughout the length of the code, that is, these have no scope. The var keyword is used to declare a local variable or object. If the var keyword is omitted, a global variable is declared.

Example:

// Declare a global globalVariable = "GLO_VAR";

The problems that are faced by using global variables are the clash of variable names of local and global scope. Also, it is difficult to debug and test the code that relies on global variables.

 

Ques. 7): What is the difference between ViewState and SessionState?

Answer: 

'ViewState' is specific to a page in a session.

'SessionState' is specific to user specific data that can be accessed across all pages in the web application.

 

Ques. 8): How can you convert the string of any base to integer in JavaScript?

Answer: 

The parseInt() function is used to convert numbers between different bases. parseInt() takes the string to be converted as its first parameter, and the second parameter is the base of the given string.

In order to convert 5F (of base 16) to integer, the code used will be -

parseInt ("5F", 16);

 

Ques. 9): What are undefined and undeclared variables?

Answer: 

Undefined variables are those that are declared in the program but have not been given any value. If the program tries to read the value of an undefined variable, an undefined value is returned.

Undeclared variables are those that do not exist in a program and are not declared. If the program tries to read the value of an undeclared variable, then a runtime error is encountered.

 

Ques. 10): What is this [[[]]]?

Answer: 

This is a three-dimensional array.

var myArray = [[[]]]; 

 

Ques. 11): Explain the working of timers in JavaScript? Also elucidate the drawbacks of using the timer, if any?

Answer: 

Timers are used to execute a piece of code at a set time or also to repeat the code in a given interval of time. This is done by using the functions setTimeout, setInterval and clearInterval.

The setTimeout(function, delay) function is used to start a timer that calls a particular function after the mentioned delay. The setInterval(function, delay) function is used to repeatedly execute the given function in the mentioned delay and only halts when cancelled. The clearInterval(id) function instructs the timer to stop.

Timers are operated within a single thread, and thus events might queue up, waiting to be executed.

 

Ques. 12): What is the use of Void(0)?

Answer: 

Void(0) is used to prevent the page from refreshing and parameter "zero" is passed while calling.

Void(0) is used to call another method without refreshing the page.

 

Ques. 13): What is the main disadvantage of using innerHTML in JavaScript?

Answer: 

The main disadvantages of using innerHTML in JavaScript are:

  • Content is replaced everywhere
  • We cannot use like "appending to innerHTML"
  • Even if you use +=like "innerHTML = innerHTML + 'html'" still the old content is replaced by html
  • The entire innerHTML content is re-parsed and build into elements, therefore its much slower
  • The innerHTML does not provide validation and therefore we can potentially insert valid and broken HTML in the document and break it

 

Ques. 14): What are the different types of errors in JavaScript?

Answer: 

There are three types of errors in JavaScript:

  • Load time errors: Errors which come up when loading a web page like improper syntax errors are known as Load time errors and it generates the errors dynamically.
  • Run time errors: Errors that come due to misuse of the command inside the HTML language.
  • Logical Errors: These are the errors that occur due to the bad logic performed on a function which is having different operation.

  

Ques. 15): What is the requirement of debugging in JavaScript?

Answer: 

JavaScript didn't show any error message in a browser. However, these mistakes can affect the output. The best practice to find out the error is to debug the code. The code can be debugged easily by using web browsers like Google Chrome, Mozilla Firebox.

To perform debugging, we can use any of the following approaches:

•     Using console.log() method

•     Using debugger keyword

 

Ques. 16): What is the 'Strict' mode in JavaScript and how can it be enabled?

Answer: 

Strict Mode adds certain compulsions to JavaScript. Under the strict mode, JavaScript shows errors for a piece of codes, which did not show an error before, but might be problematic and potentially unsafe. Strict mode also solves some mistakes that hamper the JavaScript engines to work efficiently.

Strict mode can be enabled by adding the string literal "use strict" above the file. This can be illustrated by the given example:

function myfunction() {

    "use strict";

    var v = "This is a strict mode function";

}

 

Ques. 17): What is the purpose of ‘This’ operator in JavaScript?

Answer: 

The JavaScript this keyword refers to the object it belongs to. This has different values depending on where it is used. In a method, this refers to the owner object and, in a function, this refers to the global object.

 

Ques. 18): What is Callback in JavaScript?

Answer: 

A callback is a plain JavaScript function passed to some method as an argument or option. It is a function that is to be executed after another function has finished executing, hence the name ‘call back‘.

In JavaScript, functions are objects. Because of this, functions can take functions as arguments, and can be returned by other functions.

 

Ques. 19): What are JavaScript Cookies?

Answer: 

Cookies are the small test files stored in a computer and it gets created when the user visits the websites to store information that they need. Example could be User Name details and shopping cart information from the previous visits.

 

Ques. 20): Explain what is pop()method in JavaScript?

Answer: 

The pop() method is similar as the shift() method but the difference is that the Shift method works at the start of the array. Also the pop() method take the last element off of the given array and returns it. The array on which is called is then altered.

Example:

var cloths = ["Shirt", "Pant", "TShirt"];

cloths.pop();

//Now cloth becomes Shirt,Pant

 

Ques. 21): Define event bubbling?

Answer: 

JavaScript allows DOM elements to be nested inside each other. In such a case, if the handler of the child is clicked, the handler of parent will also work as if it were clicked too.

 

Ques. 22): How are event handlers utilized in JavaScript?

Answer: 

Events are the actions that result from activities, such as clicking a link or filling a form, by the user. An event handler is required to manage proper execution of all these events. Event handlers are an extra attribute of the object. This attribute includes event's name and the action taken if the event takes place.

 

Ques: 23): Explain the role of deferred scripts in JavaScript?

Answer: 

By default, the parsing of the HTML code, during page loading, is paused until the script has not stopped executing. It means, if the server is slow or the script is particularly heavy, then the webpage is displayed with a delay. While using Deferred, scripts delays execution of the script till the time HTML parser is running. This reduces the loading time of web pages and they get displayed faster.