Explore topic-wise InterviewSolutions in Current Affairs.

This section includes 7 InterviewSolutions, each offering curated multiple-choice questions to sharpen your Current Affairs knowledge and support exam preparation. Choose a topic below to get started.

1.

Describe the different kinds of HTTP requests supported by RESTful Web services.

Answer»

Each HTTP request type in RESTful web services has a specific purpose. Below is a description of them:

  • GET: It is USED to retrieve data or resources from the server but only allows read-only access. You cannot modify it.
  • POST: It is used for CREATING a new RESOURCE.
  • PUT: This is similar to POST, but used for updating an existing resource (if the resource doesn't exist, the API will decide whether a new resource should be created).
  • DELETE: It is used to delete the resource from the server.
  • TRACE: It VALIDATES the content along with the network during an HTTP request.
2.

What is the difference between and ?

Answer»

It is true that both the <window.onload> and <onDocumentReady> FUNCTIONS perform tasks when the page has been LOADED in the BROWSER, however, the execution of the two functions differs slightly.

  • Window.onload: This event is triggered when a web page has fully loaded. In other words, it waits for the DOM and all the associated resources to load, and then executes code. DOM contains all HTML tags, like ANCHOR tag, h1 tag, p tag, etc.
  • onDocumentReady: The "onDocumentReady" method, on the other hand, executes the code when the DOM has been loaded. It typically waits for HTML tags, anchor tags, etc., but not for IMAGES, videos, or other contents.
3.

What is Type Coercion in JavaScript?

Answer»

The term type coercion refers to the PROCESS of converting VALUES from one data type to another, either automatically or implicitly. For instance, you could convert a NUMBER to a string, a string to a number, or a boolean to a number, etc.

Example: Number to String Conversion

<script> // The Number 5 is converted to // string '5' and then '+' // concatenates both strings const VALUE1 = 5; const value2 = '50'; var x = value1 + value2; document.write(x);</script>

Output: 

550

The above example SHOWS how JavaScript converted the number 5 into a string and concatenate the values together, resulting in 550. 

4.

State difference between SVG (Scalable Vector Graphics) and Canvas.

Answer»

HTML5 introduced two new graphical elements, Canvas (<canvas>) and SVG (<svg>), that make your web pages more interactive and more graphically attractive. Each has its own PROPERTIES and can be used to create graphic elements on web pages.

<svg> tag<canvas> tag
In web pages, SVG is used to define VECTOR-based graphics (vector image format). Unlike raster images (ex. .jpg, .gif, .png, etc. ), vector images can be stretched or compressed without LOSING quality.Canvas is a raster-based format composed of pixels.
SVG provides better scalability, enabling HIGH-quality printing at any resolution.The canvas is not suitable for printing at high resolutions since it has poor scalability.
Through scripting and CSS, SVG can be modified.Modifying a canvas is only possible through the script.
The performance of SVG is better when dealing with FEWER objects (<10k) or larger surfaces.Canvas performs better when there is a smaller surface area or a larger number of objects (>10k).
5.

While building a web application, how do you consider SEO, maintainability, UX, performance, and security?

Answer»

Security should be a top priority in any organization that HANDLES VITAL DATA. On the other hand, SEO and UX should be prioritized for small and medium-sized online businesses.  You will need to PAY more attention to PERFORMANCE and SEO if you write an online publication.

6.

What do you know about pair programming?

Answer»

Pair programming is sometimes REFERRED to as pairing. In pair programming, TWO programmers work together at one (single) workstation. Those who WRITE code are known as drivers, and those who MONITOR and NAVIGATE each line of code are known as navigators. Both of them may switch roles frequently.

7.

Explain DOM (Document Object Model)?

Answer»

DOM stands for Document Object Model. It is basically a cross-platform, language-independent API (Application Programming Interface) for XML (Extensible Markup Language) and HTML documents. To put it simply, DOM describes the LOGICAL structure of documents and how one can ACCESS and manipulate them. For example, here is an HTML document that illustrates the DOM hierarchy.

These documents are usually treated as a tree structure in which every node is an object that represents a specific part of the document. In a tree, each branch ends with a node, and each node contains objects. The DOM represents the webpage in a hierarchical structure in order for programmers and USERS to navigate it more easily. 

8.

Explain HTML5 Web storage.

Answer»

HTML5 has many great features, including Web Storage, which is sometimes referred to as DOM storage (Document OBJECT Model Storage). Web applications can use Web Storage to store DATA locally in the browser on the user/client’s side. Data is stored in the form of a key/value pair in the user's browser. Using web storage to store data is similar to using cookies, but web storage is faster and more convenient. Web Storage should never be used to store SENSITIVE data. It isn't "more secure" than cookies since it isn't transmitted over the wire and isn't encrypted.

Types of Web Storage:

As outlined below, there are two types of web storage with different scopes and lifespans:

  • LOCAL Storage: This storage uses Windows.localStorage object that stores data with no expiration DATE. Once stored in local storage, the data will remain available even after the user's browser is closed and reopened.
  • Session Storage: This storage uses the Windows.sessionStorage object that stores data for one or single session only. As soon as the user closes his browser, data is lost or deleted from the browser, and the session would be lost. 
9.

State the difference between span tag and div tag in HTML5.

Answer»

Both the div and span tags are used to indicate the PART of a web page. Divs are block-level ELEMENTS, whereas spans are inline elements of a web page. <div> tag is used to show block parts of the webpage whereas <span> tag is used to show inline parts of the webpage:

Example: 

<div>A 6-month online career accelerator program<span>Scaler ACADEMY<span></div>
<span> tag<div> tag
Span tag will be used for inline elements and for paragraphs.Div tags are used for block-level elements.
Typically, this tag is used to highlight any specific WORD ( or a small SECTION of a line) on a webpage.In general, it is used/attached to highlight a section on the webpage. 
In this tag, we use a specific colour code in order to highlight the HTML content.In this tag, we use borders with height and width with specified colour pixels in order to highlight the HTML content.
As it does not support the align attribute, the span tag will not appear on a new line.With support for the align attribute, the div tag will appear on a new line.
10.

List out newly introduced input types, APIs, form elements, and elements that support media content in HTML5.

Answer»

List out newly introduced input types, APIs, form elements, and elements that support media content in HTML5. 

HTML5 has been updated repeatedly in the last few years, and the addition of input types has greatly simplified its use. AMONG some of these input types are

  • Colour: Enable users to select or choose a colour using the colour picker.
  • Date: Enable users to select or choose a date from a drop-down calendar.
  • Datetime-local: Enable users to select or choose both local date and time.
  • Email: Enable users to enter an email address.
  • Month: Enable users to select or choose a month and year from a drop-down calendar.
  • Week: Enable users to select or choose week and year from a drop-down calendar.

HTML5 introduces the following new form elements:

  • <datalist>: Specifies a list of options for input controls.
  • <keygen>: Creates an encryption key.
  • <output>: Defines the result or output of an expression.
  • <progress>: Heads in the direction of 100% of the maximum value.
  • <meter>: Provides a gauge that shows a general value within a range.

The following are some of the new APIs introduced in HTML5:

  • History API: Provides programs with access to the browser's history.
  • Page visibility API: Enables us to determine the current visibility state of a page.
  • BATTERY Status API: Displays the current battery status of the DEVICE.
  • User Timing API: Provides programmers with high-precision timestamps for measuring application performance.
  • Vibration API: Provides access to the device's vibration functionality.

HTML5 includes five elements that support media as follows:

  • <audio>: Used to embed audio files in a web page
  • <video>: Used to embed video files in a web page.
  • <SOURCE>: Used for attaching multimedia files, including audio, video, and photos.
  • <embed>: Used to embed external applications, usually multimedia content such as audio or video into an HTML document.
  • <track>: Specifies text tracks for audio and video components.
11.

Explain Webpack.

Answer»

Webpack is a tool that bundles JavaScript modules, ALSO known as static module bundlers. Modules are REUSABLE chunks of code that are built from the JavaScript, node_modules, images, and CSS styles of your application, and packaged so that they can be easily added to your website. If you have a large number of files, Webpack generates a single (or a few) file that RUNS your application.

When Webpack processes your application or package, it generates a dependency graph, which consists of various modules that your webapp needs in order to function as expected. Based on this graph, it then creates a new package that contains only the bare minimum files required, often only ONE or a few bundle.js files which can be easily plugged into the HTML file and used in the application.

12.

What do you mean by ETag (Entity Tag) and how does it work?

Answer»

The ETag (entity tag) is a part of the HTTP protocol. This is one of several mechanisms that HTTP provides to validate Web caches, which allows conditional REQUESTS to be made from a browser to resources. Moreover, Etags make SURE that simultaneous updates of the same resource don't overwrite each other (mid-air collisions).

ETags are opaque identifiers assigned by a server to a specific version of a resource FOUND at a specific URL. Every time the resource representation at that URL changes, an entirely new ETag is assigned. As such, ETags can be COMPARED in the same way as fingerprints and determine if two representations of a resource are identical.

Syntax:

ETag: W/"<etag_value>"

ETag: "<etag_value>"

13.

Explain CORS (Cross-Origin Resource Sharing) and Write its Importance.

Answer»

CORS stands for Cross-origin resource sharing. It is basically defined as a browser MECHANISM that enables web pages from one domain to have controlled access to resources that are located at different domains (cross-domain request). In other words, it allows scripts running on a browser client to interact with and access resources from other origins. It provides and extends flexibility to the SOP (Same-Origin Policy). A same-origin policy restricts a website's ability to access resources outside its source domain. For EXAMPLE, if a JAVASCRIPT app wanted to call an API (Application Programming Interface) running on another domain, it would be blocked and prevented from doing so because of the SOP. Due to restrictions caused by the same-origin policy, CORS was introduced.

When a website's CORS policy is set up poorly, it also poses the risk of cross-domain attacks. As such, it cannot prevent cross-origin attacks such as  CSRF (Cross-Site Request Forgery).

14.

List the advantages of HTTP/2 over HTTP 1.1.

Answer»

Hypertext Transfer Protocol (HTTP) is a set of standard protocols allowing INTERNET users to exchange website knowledge on WWW (World Wide Web). HTTP has gone through four iterations since it was introduced in 1991 i.e., HTTP/0.9, HTTP/1.0, HTTP/1.1, and HTTP/2.0. In 2015, HTTP/2 was released as a major revision to HTTP/1.1. HTTP/2.0 has the following advantages over HTTP/1.1:

  • Increased performance: It was designed specifically to speed up page loading and reduce round-trip time (RTT) for resource-intensive websites.
  • Handle multiple resources: With HTTP 1.1, the web pages were manageable simply by using HTML markups and images. But with HTTP 2.0, there are now multiple resources available for web pages, including images, fonts, scripts, and more. HTTP 1.1 was not designed to handle such a large amount of resources today.
  • Multiplexing: Multiplexing is fully implemented in HTTP/2. It means that multiple requests are sent between browsers and servers simultaneously over a single TCP connection. Consequently, several elements of a web page can be delivered via a single TCP connection. As a result, the HTTP/1.1 head-of-line blocking problem is RESOLVED, in which a packet at the front of the line blocks the transmission of other packets.
  • Header Compression: HTTP 2.0 has the ability to compress HTTP headers to reduce overhead. When HTML headers on web pages are compressed, they can be sent between the browser and server in one trip, over a single TCP connection.
  • Server push: HTTP/2 servers are able to push resources into a browser's cache even before they are requested. By doing this, browsers can display content without requiring additional requests.
  • BINARY protocols: HTTP/2 use binary protocols, not textual. HTML/2's binary protocols consume less bandwidth, can be parsed more efficiently, and are less error-prone compared to HTTP/1.1's textual protocols.
15.

What are the key responsibilities of Web Developers?

Answer»

It is generally expected that web developers will be able to perform the following tasks: 

  • Build products using HTML, CSS, JavaScript, PHP (Hypertext Preprocessor), and other relevant coding languages.
  • Design, develop, test, DEBUG, and deploy applications in a cross-platform, cross-browser environment.
  • Coordination with designers and programmers for the DEVELOPMENT of projects.
  • Develop design specifications/patterns for OPTIMIZING web programs.
  • Identifying and fixing bugs, troubleshooting, and resolving website issues.
  • Taking care of the technical aspects of the SITE, such as its cache and performance (which indicate how fast a site will run and how much traffic it can handle).
  • Providing support and assistance with web management best practices.
  • Keep up with the latest technology.
  • Maintain and update websites to meet MODERN web standards.
  • Monitor web traffic.
Previous Next