Showing posts with label java. Show all posts
Showing posts with label java. Show all posts

November 17, 2021

Top 20 Apache ActiveMQ Interview Questions & Answers

 

Ques: 1). What exactly is ActiveMQ?

Answer: 

Apache Message-oriented middleware (MOM) is a type of software that transmits messages between applications, and ActiveMQ is one of them. ActiveMQ facilitates loose coupling of elements in an IT system using standards-based, asynchronous communication, which is frequently basic to business messaging and distributed applications. Messages are translated from sender to receiver using ActiveMQ. Instead of requiring both the client and the server to be online at the same time in order to interact, it can connect numerous clients and servers and allow messages to be queued.


AWS Lambda Interview Questions & Answers


Ques: 2). In Apache ActiveMQ, what are clusters?

Answer: 

Load balancing of messages on a queue between consumers is supported by ActiveMQ in a stable and high-performance manner. This scenario is known as the competing consumers pattern in corporate integration. The principle is illustrated in the diagram below: Interview questions for Activemq

The burden is distributed in an extremely fluid manner. In high-load periods, more consumers might be provisioned and joined to the queue without changing any queue setup, as the new consumer would behave like any other competing consumer. Better availability than load-balanced systems. To determine whether real-servers are offline, load balancers often use a monitoring system. A failed consumer will not compete for messages if there are competing consumers, so messages will not be given to it even if it is not monitored.


AWS Cloudwatch interview Questions & Answers


Ques: 3). What Is The Difference Between ActiveMQ And AmQP?

Answer: 

The Advanced Message Queue Protocol is a wire-level protocol for client-to-messaging-broker communication that serves as a specification for how messaging clients and brokers will interact.

AMQP is a message protocol rather than a messaging system like ActiveMQ.

Open wire protocols, such as OpenWire, a fast binary format, are supported by AMQP.

Stomp is a text-based protocol that is simple to implement.

MQTT is a little binary format designed for restricted devices over a shaky network.


AWS Cloud Support Engineer Interview Question & Answers


Ques: 4). What distinguishes ActiveMQ from other messaging systems?

Answer: 

  • It is a Java messaging service implementation, therefore it contains all of Java's features.
  • Extremely persistent
  • It has a high level of security and authentication.
  • Various brokers can form a cluster and collaborate with one another.
  • ActiveMQ offers a number of client APIs in a range of languages.


AWS Solution Architect Interview Questions & Answers


Ques: 5). What are the most important advantages of ActiveMQ?

Answer: 

  • Allows users to combine many languages with various operating systems.
  • Allows for location transparency.
  • Communication that is both reliable and effective
  • It's simple to scale up and offers asynchronous communication.
  • Reduced coupling


AWS RedShift Interview Questions & Answers


Ques: 6). What are ActiveMQ's biggest drawbacks?

Answer: 

It's a complicated mechanism that only allows one thread per connection.


AWS DevOps Cloud Interview Questions & Answers


Ques: 7), In ActiveMQ, what is a topic?

Answer: 

Virtual Topics are a hybrid of Topics and Queues, with listeners consuming messages from the queues as messages to the topic.

ActiveMQ assists in replicating and duplicating every message from the topic to the actual consumers queues.


AWS(Amazon Web Services) Interview Questions & Answers


Ques: 8). What is the difference between Activemq and Fuse Message Broker?

Answer: 

Multiple Protocol Messaging is a Java-based message broker that supports industry-standard protocols and allows users to choose from a wide range of client languages, including JavaScript, C, C++, and Python.

Fuse Message Broker is a distributor of FuseSource's Apache ActiveMQ, which it develops and updates as part of the Apache ActiveMQ community.

Bug fixes are more likely to come from the Fuse Broker release than from an official Apache ActiveMQ release.


AWS Database Interview Questions & Answers


Ques: 9). What exactly is KahaDB?

Answer: 

KahaDB is a file-based persistence database that runs on the same machine as the message broker. It has been designed to be persistent in a short amount of time. Since ActiveMQ 5.4, it has been the default storage mechanism. Compared to its predecessor, the AMQ Message Store, KahaDB consumes fewer file descriptors and recovers faster.

 

Ques: 10). What exactly is LevelDB?

Answer: 

LevelDB is a somewhat faster index than KahaDB, with slightly better performance figures. The LevelDB store will allow replication in forthcoming ActiveMQ releases.

 

Ques: 11). What's the difference between RabbitMQ and ActiveMQ?

Answer: 

ActiveMQ is a Java-scripted open-source message broker that is built on the Java Message Service client. The RabbitMQ protocol is based on the Advanced Message Queuing protocol.

 

Ques: 12). What are the benefits of using a combination of topics and queues instead of traditional topics?

Answer: 

There will be no lost communications even if a customer is offline. All messages are copied to the queues that have been registered by ActiveMQ.

A dead letter queue will be set up if a customer is unable to process a message. Without affecting the other consumers, the consumer can be resolved and the message forwarded to his own dedicated queue.

To implement a load balancing mechanism we can register multiple instances of a consumer on a queue.

 

Ques: 13). If the ActiveMQ server is unavailable, what should I do?

Answer: 

This begins with ActiveMQ's storage mechanism. Non-persistent messages are stored in memory under typical conditions, while persistent messages are stored in files, with their maximum limitations set in the configuration file's node. When the number of non-persistent messages reaches a specific threshold and memory becomes scarce, ActiveMQ will write the non-persistent messages in memory to a temporary file to free up space Despite the fact that they are all saved in files, the distinction between persistent messages and non-persistent temporary files is that persistent messages will be restored from the file after restart, whereas non-persistent temporary files would be removed immediately.

 

Ques: 14). What happens if the file size exceeds the configuration's maximum limit?

Answer: 

Set a 2GB persistent file limit and mass-produce persistent messages until the file exceeds its limit. The producer is currently prohibited, but the consumer can connect and consume the message as usual. The producer can continue to transmit messages after a portion of the message has been eaten and the file has been erased to make room, and the service will automatically revert to normal.

Set a 2GB limit on temporary files, mass-produce non-persistent messages, and write temporary files. When the maximum limit is reached, the producer is blocked, and consumers can still connect but not consume messages, or consumers who were previously sluggish consumers suddenly consume Stop. The complete system is linked, but it is unable to give services, causing it to hang.

 

Ques: 15). What is message-oriented middleware, and how does it work?

Answer: 

Message-oriented middleware (MOM) is a software or hardware framework that allows distributed systems to send and receive messages. MOM simplifies the development of applications that span different operating systems and network protocols by allowing application modules to be distributed across heterogeneous platforms. The middleware establishes a distributed communications layer that hides the intricacies of the multiple operating systems and network interfaces from the application developer.

 

Ques: 16). What is the benefit of Activemq over other options such as databases?

Answer: 

Activemq is a messaging system that allows two distributed processes to communicate successfully. It can keep messages in a database to communicate between processes, but you'd have to erase them as soon as they were received. For each message, this means a row insert and remove. When you try to scale that up to hundreds of messages per second, databases start to break down.

Message-oriented middleware, such as ActiveMQ, is designed to handle these scenarios. They assume that messages will be erased promptly in a healthy system and can make optimizations to prevent the overhead. It can also push messages to consumers rather than requiring them to poll for fresh messages via SQL queries. This minimises the amount of time it takes for new messages to be processed into the system.

 

Ques: 17). What are some of the platforms supported by ActiveMQ?

Answer: 

Some of the common platforms supported by ActiveMQ include:

Any java platform that has an update of 5.0 or more.

J2EE 1.4 is another platform

JMS 1.1

JCA 1.5 resource adaptor

 

Ques: 18). Make a distinction between ActiveMQ and Mule.

Answer: 

ActiveMQ is a messaging service with a lot of options for both the broker and the client. Mule, on the other side, is an ESB that may provide executive functionality to merely the broker by exchanging messages between various software components.

Mule's architecture is such that it is designed to provide a programming configuration that is feasible for integrating applications between a database and an operating system. Mule, on the other hand, does not support any form of native messaging system, hence it is typically used in conjunction with ActiveMQ. the user is required to introduce different and unique frameworks to define various boundaries for connectivity.

 

Ques: 19). What is the process for dealing with an application server using JMS connections?

Answer: 

The server session is created with the help of an application server, which then stores them in a pool. An association buyer uses the server's session to place messages in JMS sessions. The JMS session is created by a server session. The messaging audience is created by an application produced by application software engineers.

 

Ques: 20). What distinguishes ActiveMQ from the spread toolkit?

Answer: 

Spread Toolkit is a C++ library for informing, with only rudimentary support for JMS. It does not support robust informing, exchanges, XA, or JMS 1.1 in its entirety. It's also depending on a locally installed version of Spread inspiration. Apache ActiveMQ, on the other hand, is the JMS provider used in Apache Geronimo. It is J2EE 1.4 certified in Geronimo and is a completely pure version of the Java programming language. ActiveMQ supports real-time and persistent messaging, exchanges, XA, J2EE 1.4, JMS 1.1, JCA 1.5, and a slew of other features like Message Groups and Clustering.



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.