Sample Questions M1
Sample Questions M1
Sample Questions M1
2. Browser Engine: It connects the UI (User Interface) and the rendering engine as a
bridge. It queries and manipulates the rendering engine based on inputs from
several user interfaces.
4. Networking: It retrieves the URLs by using internet protocols like HTTP or FTP. It
is responsible for maintaining all aspects of Internet communication and
security. Furthermore, it may be used to cache a retrieved document to reduce
network traffic.
7. Data Storage: The data storage is a persistence layer that is used by the browser
to store all sorts of information locally, like cookies. A browser also supports
different storage mechanisms such as IndexedDB, WebSQL, localStorage, and
FileSystem. It is a database stored on the local drive of your computer where the
browser is installed. It handles user data like cache, bookmarks, cookies, and
preferences.
2. HTTPS Methods
=> HTTP (Hypertext Transfer Protocol) defines several methods or verbs that indicate
the desired action to be performed on a resource identified by a URL. These HTTP
methods are used in requests to interact with web servers and manipulate data. Here
are the most commonly used HTTP methods:
1. *GET:*
- The GET method is used to retrieve data from a specified resource.
- It should not have any side effects on the server or data, meaning it should be safe
and idempotent (repeated requests have the same result).
- Example: `GET /api/products` retrieves a list of products.
2. *POST:*
- The POST method is used to submit data to be processed to a specified resource.
- It can create new resources or update existing ones, and it may have side effects.
- Example: `POST /api/products` creates a new product.
3. *PUT:*
- The PUT method is used to update a resource or create it if it doesn't exist at the
specified URL.
- It is idempotent, meaning multiple identical requests should have the same effect as
a single request.
- Example: `PUT /api/products/123` updates the product with ID 123.
4. *PATCH:*
- The PATCH method is used to apply partial modifications to a resource.
- It is typically used to update specific fields of an existing resource.
- Example: `PATCH /api/products/123` updates specific attributes of the product with
ID 123.
5. *DELETE:*
- The DELETE method is used to request the removal of a resource at the specified
URL.
- It is idempotent, meaning multiple identical requests should have the same effect as
a single request.
- Example: `DELETE /api/products/123` deletes the product with ID 123.
6. *HEAD:*
- The HEAD method is similar to GET but requests only the headers of the response,
not the actual data.
- It is useful for checking resource metadata and status without downloading the entire
content.
- Example: `HEAD /api/products` retrieves only the headers for the list of products.
7. *OPTIONS:*
- The OPTIONS method is used to describe the communication options for the target
resource.
- It can be used to retrieve information about the allowed methods, supported
headers, and other metadata about a resource.
- Example: `OPTIONS /api/products` retrieves information about the available
methods and headers for the products resource.
8. *CONNECT:*
- The CONNECT method is used to establish a network connection to a resource,
typically for use with proxy servers.
- It is less commonly used in web applications and is mainly used for tunneling.
9. *TRACE:*
- The TRACE method is used to retrieve a diagnostic trace of the actions that have
been performed by a request on the target resource.
- It is primarily used for debugging and should be disabled on production servers due
to security concerns.
These HTTP methods provide a standardized way for clients (e.g., web browsers,
mobile apps) to interact with web servers and perform various actions on resources.
The choice of method depends on the operation you want to perform and the semantics
associated with each method.
GET Method:
1. *Purpose:* The primary purpose of the GET method is to retrieve data from a
specified resource, typically identified by a URL. It is a read-only operation.
2. *Safety:* GET requests are considered safe, meaning they should not have
any side effects on the server or data. Repeating a GET request multiple times
should yield the same result, and it should not modify any server state.
3. *Idempotence:* GET requests are idempotent, which means that making the
same GET request multiple times will have the same effect as a single request. It
does not change the state of the server or resource.
4. *Data Sending:* Data is usually sent to the server through the URL as query
parameters. For example, in a URL like
`https://example.com/api/products?id=123`, the `id` parameter is sent as part of
the GET request.
5. *Security:* GET requests are visible in the URL, which means any data sent
with a GET request is exposed in the browser's address bar and server logs.
Therefore, sensitive data should not be sent via GET requests.
POST Method:
2. *Safety:* POST requests are not safe as they may have side effects on the
server or data. They can create new resources, update existing ones, or perform
other actions specified by the server.
4. *Data Sending:* Data is sent in the request body of a POST request, allowing
for the transmission of larger and more complex data structures, such as JSON
or form data.
5. *Security:* POST requests do not expose data in the URL, making them more
suitable for sending sensitive information, like passwords or user data. However,
they should still be secured using encryption (e.g., HTTPS) for data privacy.
In summary, GET is used for retrieving data and should not modify server state, while
POST is used for submitting data to create or update resources and can have side
effects on the server. Choosing between GET and POST depends on the specific use
case and the desired behavior when interacting with web resources.
4. Differentiate between HTTPS & HTTP.
=>
HTTP uses port number HTTPs uses 443 port number for
3.
80 for communication. communication.
HTTP is considered to be
4. HTTPs is considered as secure.
unsecure.
In HTTP, Encryption is
6. Encryption is present in HTTPS.
absent.
SSL TLS
SSL (Secure Socket Layer) supports TLS (Transport Layer Security) does
the Fortezza algorithm. not support the Fortezza algorithm.
SSL (Secure Socket Layer) is the 3.0 TLS (Transport Layer Security) is the
version. 1.0 version.
In SSL( Secure Socket Layer), the In TLS(Transport Layer Security), a
Message digest is used to create a Pseudo-random function is used to
master secret. create a master secret.
SSL uses port to set up explicit TLS uses protocol to set up implicit
connection. connection.
JSON XML
It is based on JavaScript
It is derived from SGML.
language.
It is a way of representing It is a markup language and uses tag
objects. structure to represent data items.
Its files are very easy to read Its documents are comparatively difficult to
as compared to XML. read and interpret.
URN stands
URI stands for Uniform URL stands for Uniform Resource for Uniform
1
Resource Identifier Location Resource
Name
URN is a
URI is a superset of URL URL is a subset of the Uniform subset of the
2
& URN Resource Uniform
Resource.
URN does
URI includes components URL includes
not include
5 like scheme, authority, protocol,domain,path,hash,query,string
any
path, query, etc. etc
component
1. Statelessness : Each request from a client to a server must contain all the information
needed to understand and fulfill the request. The server should not rely on any past
requests or sessions stored on the server. This simplifies server implementation and
allows for easy scalability.
2. Client-Server Architecture : REST separates the client and server components,
allowing them to evolve independently. This separation enhances the scalability and
flexibility of the system. Clients are responsible for the user interface and user
experience, while servers are responsible for processing requests and managing
resources.
4. HTTP Methods : RESTful APIs use standard HTTP methods for performing CRUD
(Create, Read, Update, Delete) operations on resources. The most commonly used
HTTP methods are:
- GET: Retrieve a resource.
- POST: Create a new resource.
- PUT: Update an existing resource or create one if it doesn't exist.
- DELETE: Remove a resource.
- PATCH: Partially update a resource.
11. HATEOAS (Hypermedia as the Engine of Application State) : This principle suggests
that the API should provide links to related resources in the responses, allowing clients
to discover and navigate the API dynamically rather than relying on prior knowledge of
resource URLs.
9. Explain DNS.
=> DNS, which stands for Domain Name System, is a fundamental technology used on
the internet to translate human-friendly domain names into machine-readable IP
addresses. It serves as a directory that enables users to access websites, send emails,
and perform various online activities using easy-to-remember domain names rather
than having to remember numeric IP addresses. Here's an explanation of how DNS
works and its key components:
3. DNS Resolver : When you enter a domain name in your web browser, your computer
or device first contacts a DNS resolver (usually provided by your internet service
provider or a third-party DNS service). The resolver's job is to find the corresponding IP
address for the requested domain.
4. DNS Query : The DNS resolver sends a DNS query to a DNS server to find the IP
address associated with the requested domain. The DNS query contains the domain
name (e.g., www.example.com).
5. DNS Servers : DNS servers are distributed throughout the internet and store
databases of domain name-to-IP address mappings. There are several types of DNS
servers in the DNS hierarchy:
- Root DNS Servers : These are the top-level servers in the DNS hierarchy. They store
information about the authoritative DNS servers for each top-level domain (TLD), such
as .com, .org, and .net.
- Top-Level Domain (TLD) DNS Servers : These servers handle requests for domains
within their respective TLDs (e.g., .com TLD servers handle requests for domain names
ending in .com).
- Authoritative DNS Servers : These servers hold the official DNS records for specific
domains. They provide the IP address associated with a domain name.
- Recursive DNS Servers : These servers are typically operated by ISPs or DNS
service providers. They receive DNS queries from resolvers, perform the necessary
lookups, and return the IP address to the resolver.
6. Caching : DNS resolvers and intermediate DNS servers often cache the results of
DNS queries for a certain period of time. Caching helps reduce the load on the DNS
infrastructure and speeds up subsequent requests for the same domain.
7. Response : Once the DNS resolver receives the IP address from a DNS server, it
returns this information to the requesting device. The device can then use the IP
address to establish a connection with the server hosting the requested website or
service.
8. TTL (Time to Live) : DNS records include a TTL value, which specifies how long the
record can be cached by DNS resolvers and servers. After the TTL expires, a new DNS
query is required to refresh the IP address mapping.
In summary, DNS plays a critical role in the functioning of the internet by providing a
mapping between human-readable domain names and numerical IP addresses. This
system allows users to access websites and services using easily recognizable names
while enabling the underlying infrastructure to efficiently route data to the correct
destinations.
10. Features of Browser.
=> A browser is a software program that is used to explore, retrieve, and display the
information available on the World Wide Web. This information may be in the form of
pictures, web pages, videos, and other files that all are connected via hyperlinks and
categorized with the help of URLs (Uniform Resource Identifiers). For example, you are
viewing this page by using a browser.
1. Refresh button: Refresh button allows the website to reload the contents of the
web pages. Most of the web browsers store local copies of visited pages to
enhance the performance by using a caching mechanism. Sometimes, it stops
you from seeing the updated information; in this case, by clicking on the refresh
button, you can see the updated information.
2. Stop button: It is used to cancel the communication of the web browser with the
server and stops loading the page content. For example, if any malicious site
enters the browser accidentally, it helps to save from it by clicking on the stop
button.
3. Home button: It provides users the option to bring up the predefined home page
of the website.
4. Web address bar: It allows the users to enter a web address in the address bar
and visit the website.
5. Tabbed browsing: It provides users the option to open multiple websites on a
single window. It helps users to read different websites at the same time. For
example, when you search for anything on the browser, it provides you a list of
search results for your query. You can open all the results by right-clicking on
each link, staying on the same page.
6. Bookmarks: It allows the users to select particular website to save it for the later
retrieval of information, which is predefined by the users.
1. HTML Parsing :
- When you enter a URL or click on a link in your web browser, it sends a request to
the web server to retrieve the web page's HTML content.
- The rendering engine receives the HTML response from the server.
4. Layout (Reflow) :
- The rendering engine calculates the layout of the web page, often referred to as
"reflow" or "layout."
- It determines the size and position of each element on the page, considering factors
like element dimensions, margins, padding, and any positioning properties specified in
the CSS.
5. Painting :
- Once the layout is calculated, the rendering engine proceeds to paint or render the
web page on the screen.
- It converts the DOM tree, along with the computed CSS styles and layout
information, into pixels that form the visual representation of the web page.
6. Rendering Updates :
- Web pages are not static; they can change in response to user interactions or
JavaScript events.
- The rendering engine continuously monitors for changes, and when something
changes (e.g., due to user input or a dynamic update via JavaScript), it re-evaluates the
affected parts of the DOM, recalculates layout, and repaints only the necessary regions
to update the display.
7. JavaScript Execution :
- In addition to handling HTML and CSS, the rendering engine can execute JavaScript
code embedded within the web page.
- JavaScript can manipulate the DOM, trigger rendering updates, and interact with
web services to add dynamic behavior to the web page.
8. User Interaction :
- The rendering engine also manages user interactions, such as mouse clicks,
keyboard input, and touch events.
- It listens for user input and executes corresponding actions like navigating to links,
submitting forms, or triggering JavaScript events.
In summary, a rendering engine in a web browser plays a crucial role in interpreting and
displaying web content. It begins by parsing HTML and CSS, constructing a DOM tree,
calculating layout, and painting the web page. It also executes JavaScript and handles
user interactions to create the interactive and visually appealing web experience that
users interact with on their devices.
12. What is DNS? Explain domain name and sub-domain name
with example.
=> “Refer DNS from 9 question”.
A domain name and a subdomain name are both parts of a hierarchical system used to
identify resources on the internet. Let's explore each term with examples:
1. Domain Name :
- Second-Level Domain (SLD) : This is the primary part of the domain name and
typically represents an organization, business, or entity. It is chosen by the domain
owner and should be unique within a top-level domain (TLD).
- Top-Level Domain (TLD) : This is the last part of the domain name and represents
the type or category of the domain. Common TLDs include .com, .org, .net, .gov, .edu,
and many more.
In this example, "www" is often a subdomain (commonly used for the web), "example"
is the second-level domain, and "com" is the top-level domain.
2. Subdomain Name :
Subdomains are versatile and can be used for various purposes, such as creating a
blog, hosting a forum, setting up a mobile version of a site, or providing specific services
like email (`mail.example.com`) or an e-commerce store (`store.example.com`). They
allow website owners to organize their content and services logically while maintaining a
consistent brand identity through the main domain.
The Document Object Model (DOM) is a programming interface for web documents. It
represents the structure of a web page as a tree-like structure, where each node in the
tree corresponds to a part of the page (e.g., elements, attributes, text), and you can use
JavaScript to interact with and manipulate these nodes. The DOM provides a way for
JavaScript to dynamically access and update the content, structure, and style of a web
page.
The Document object provides various methods and properties to interact with the web
page's structure and content. Here are some common methods of the Document object:
1. getElementById(id) :
- This method returns a reference to the first element in the document with the
specified `id` attribute.
- Example:
2. getElementsByClassName(className) :
- This method returns a live HTMLCollection of elements that have the specified class
name.
- Example:
3. getElementsByTagName(tagName) :
- This method returns a live HTMLCollection of elements with the specified tag name.
- Example:
4. querySelector(selector) :
- This method returns the first element that matches the specified CSS selector.
- Example:
5. querySelectorAll(selector) :
- This method returns a static NodeList of all elements that match the specified CSS
selector.
- Example:
6. createElement(tagName) :
- This method creates a new HTML element with the specified tag name.
- Example:
8. removeChild(node) :
- This method removes a child node from its parent node.
- Example:
9. setAttribute(name, value) :
- This method sets or updates an attribute of an element with the specified name and
value.
- Example:
element.setAttribute("class", "newClass");
button.addEventListener("click", function() {
alert("Button clicked!");
});
These are just some of the commonly used methods of the Document object in
JavaScript. The DOM provides a rich set of methods and properties that enable you to
create, manipulate, and interact with web page elements dynamically.