Viva Questions

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

MCA Sem – I Web Technology

Question Bank
Module 1:

What is api?

Ans:
API stands for Application Programming Interface. It is a set of rules, protocols, and
tools that allows different software applications to communicate with each other.

In simpler terms, an API is a way for software applications to talk to each other and
exchange data. For example, when you use a weather app on your phone, the app
communicates with a weather API to retrieve up-to-date weather data for your
location.

1. What is Node JS?

Node.js is an open-source, cross-platform JavaScript runtime environment that


allows developers to build scalable, high-performance applications for the
server-side.

2. Advantages of Node.js

Cross-platform support: Node.js runs on multiple operating systems, including


Windows, macOS, and Linux.
3. How traditional model work?

4. Node.js Process Model V/S Traditional Web Server Model


The Node.js process model is quite different from the traditional web server model.
In the traditional model, a web server creates a new thread or process for each client
request, and these threads/processes handle the request and send a response back
to the client. Each thread/process has its own memory space, which can limit the
number of concurrent connections that the server can handle.

In contrast, Node.js uses a non-blocking, event-driven I/O model that allows it to


handle multiple concurrent connections with a single thread. When a client sends a
request to a Node.js server, the server doesn't create a new thread/process to handle
the request. Instead, it uses an event loop and asynchronous callbacks to handle the
request and send a response back to the client. This approach allows Node.js to
handle a large number of concurrent connections without the overhead of creating
new threads/processes for each request.
Another advantage of the Node.js process model is that it uses a modular
architecture that makes it easy to write and maintain code. Node.js modules are
small, focused units of code that can be combined to build larger applications, and
they can be easily shared and reused by other developers.

Overall, the Node.js process model offers a modern, scalable approach to building
web applications that leverages the strengths of JavaScript and the efficiency of
asynchronous, event-driven programming.
5. Synchronous V/S Asynchronous programming

Synchronous programming is a traditional approach in which the program executes


commands in a sequence, one at a time, and waits for each command to complete
before moving on to the next one. In this approach, if an I/O operation, such as
reading from a file or waiting for a network request, is initiated, the program will
block and wait until the operation is completed before continuing with the next
command.

In contrast, asynchronous programming allows a program to execute multiple


commands simultaneously, without waiting for each command to complete before
moving on to the next one. In this approach, when an I/O operation is initiated, the
program will continue executing other commands while waiting for the operation to
complete. Once the operation is completed, a callback function is called to notify the
program that the result is ready.

Asynchronous programming is typically used in systems that require high


concurrency, such as network servers, where multiple requests may be received and
processed simultaneously. Asynchronous programming allows the system to handle
multiple requests without blocking or slowing down other parts of the system

6. How REPL works?

A Read-Eval-Print Loop, or REPL, is a computer environment where user inputs


are read and evaluated, and then the results are returned to the user.
REPLs provide an interactive environment to explore tools available in specific
environments or programming languages.

7. Applications of Node JS

1. Web application development: Node.js is widely used for building web


applications and APIs. Its event-driven, non-blocking I/O model makes it
well-suited for handling large amounts of data and concurrent connections.
2. Real-time applications: Node.js is used for building real-time applications
such as chat apps, online gaming platforms, and collaboration tools. Its
event-driven architecture allows for real-time data processing and handling.
3. Internet of Things (IoT): Node.js is used for building IoT applications, which
involve connecting devices to the internet and processing data from them.
Node.js' lightweight and modular architecture makes it well-suited for this use
case.
4. Streaming services: Node.js is used for building streaming services such as
video and audio streaming platforms. Its ability to handle large amounts of
data and concurrent connections make it well-suited for this use case.

Module 2

1. What is Event Emitter API and how it works?


The Event Emitter API is a Node.js module that provides a way to handle events in a
Node.js application. It allows developers to create custom events and emit them, as
well as register listeners to handle those events when they occur.

The basic idea behind the Event Emitter API is that an object, typically called an
"emitter", is capable of emitting events, and other objects can register themselves as
"listeners" for those events. When the emitter emits an event, all registered listeners
are notified, and their registered event handlers are executed.

2. Call-back is the standard call back pattern?


The "callback pattern" is a common design pattern used in JavaScript and other
programming languages. It involves passing a function (known as a "callback
function") as an argument to another function, which will then call the callback
function at a later time, typically after completing some asynchronous operation.

The basic idea is that the callback function will be executed when the asynchronous
operation is complete, allowing the calling code to perform some action in response
to the result of that operation

3. What is timer API and any three timer methods?


The Timer API in JavaScript provides a way to schedule code execution at a specific
time or repeatedly after a certain delay. This is useful for scenarios where you want
to run some code after a certain time delay or at a specific interval.
setTimeout: This method is used to schedule a one-time execution of a function after a
specified delay.
setInterval: This method is used to repeatedly execute a function at a specified
interval.
clearTimeout and clearInterval: These methods are used to cancel the execution of a
previously scheduled setTimeout or setInterval operation, respectively.

4. How to schedule and cancel any event?


clearTimeoutand clearInterval: These methods are used to cancel the execution of a
previously scheduled setTimeout or setInterval operation, respectively.
Module 3:

1. File system methods

1. fs.readFile(): This method reads the contents of a file asynchronously and


returns the data as a buffer object or a string, depending on the specified
encoding.
2. fs.writeFile(): This method writes data to a file asynchronously. If the file
already exists, it will be overwritten with the new data.
3. fs.appendFile(): This method appends data to a file asynchronously. If the file
doesn't exist, it will be created.
4. fs.rename(): This method renames a file or directory asynchronously

2. Functions to read and write file


fs.readFile() method is used to read the content of a file. The method accepts a file
path as the first argument, options and callback function as optional arguments.
fs.writeFile() method is used to write the content to a file. The method accepts a file
path, content to be written, options, and callback function as optional arguments.
3. HTTP object & Server Creation

4. How piping works


In Node.js, piping is a mechanism to efficiently transfer data between two streams. A
stream is a sequence of data that can be read or written, often used to represent
data being transmitted over a network or being read from a file.

Piping in Node.js works by connecting the output of one stream to the input of
another stream, creating a pipeline for the data to flow through. This is done using
the pipe() method, which is available on all readable and writable streams in Node.js.

Module 4:

1. Functions to execute database operations

1. mysql: A popular Node.js library for working with MySQL databases. It


provides a simple and efficient API for executing SQL queries and managing
database connections. Here's an example of how to use the mysql library to
execute a simple query:

In this example, we're creating a connection to a MySQL database using the


mysql.createConnection() method. We then connect to the database using the
connection.connect() method.

We execute a simple SELECT query to fetch all rows from the customers table using
the connection.query() method. When the query completes, the results are returned to
the callback function, which logs the results to the console.

2. Command of SQL
SQL (Structured Query Language) is a programming language used to manage
and manipulate data in relational databases. Here are some of the most
common SQL commands:
SELECT, INSERT, UPDATE, DELETE, CREATE

Module 5:

1. What is Angular JS ?

AngularJS is an open-source, front-end JavaScript framework for building


dynamic, single-page web applications. It was developed by Google and released
in 2010. AngularJS provides a set of tools and features that make it easier to
create complex web applications using a declarative approach.
AngularJS is based on the Model-View-Controller (MVC) design pattern, which
separates the application into three interconnected components: the model,
which represents the data and business logic; the view, which represents the user
interface; and the controller, which acts as an intermediary between the model
and the view, handling user input and updating the model and view as needed.
2. Advantages of Angular JS.

1. Data binding: AngularJS provides two-way data binding, which means that
changes to the model are automatically reflected in the view, and vice versa.
2. Dependency injection: AngularJS uses a dependency injection system to
make it easier to manage and test complex applications.
3. Directives: AngularJS provides a set of built-in directives that can be used to
extend HTML with custom behavior and functionality.
4. Services: AngularJS provides a set of built-in services that can be used to
share data and functionality across different parts of an application.
5. Routing: AngularJS provides a built-in routing system that can be used to
create single-page applications with multiple views

3. What is MVC Architecture?


MVC (Model-View-Controller) is a software architecture pattern that separates an
application into three interconnected components:

1. Model: The model represents the data and business logic of the application. It
manages the data, validates user input, and responds to requests from the
controller.
2. View: The view represents the user interface of the application. It displays the
data from the model and receives user input, which is then passed on to the
controller.
3. Controller: The controller acts as an intermediary between the model and the
view. It receives user input from the view, interacts with the model to retrieve
or modify data, and updates the view with the new data.

4. Difference between Angular JS and Angular


AngularJS and Angular are both front-end web application frameworks developed by
Google, but they are quite different from each other in terms of architecture, syntax,
and features.

1. Architecture: AngularJS is based on the Model-View-Controller (MVC)


architecture pattern, while Angular is based on the component-based
architecture pattern. Angular uses a hierarchy of components to organize the
application and manage its state, while AngularJS relies on controllers and
scopes to manage the data and behavior of the application.
2. Syntax: AngularJS uses JavaScript syntax with some custom directives, such
as ng-repeat and ng-model, to bind data to the view and handle events.
Angular, on the other hand, uses TypeScript, a superset of JavaScript that
adds features like static typing, decorators, and interfaces to the language.
3. Features: Angular is a more modern and feature-rich framework than
AngularJS. It includes features like reactive programming with RxJS, lazy
loading, server-side rendering, and a powerful command-line interface (CLI)
for generating code and managing dependencies. AngularJS, on the other
hand, has a simpler feature set and does not include many of the advanced
features found in Angular.
4. Performance: Angular is generally faster and more performant than
AngularJS, thanks to its improved architecture, optimized rendering engine,
and use of modern browser APIs like Web Components.

5. What are ng directives and how to use it?


In AngularJS, ng directives are built-in directives that are used to extend HTML with
custom behavior and functionality. They are prefixed with "ng" to indicate that they
are Angular-specific directives. There are several ng directives available, including:

1. ng-app: Defines the root element of the AngularJS application and initializes
the framework.
2. ng-model: Binds an input, select, or textarea element to a property on the
scope, enabling two-way data binding.
3. ng-repeat: Loops over a collection and generates HTML elements for each
item in the collection.
4. ng-click: Binds a function to a click event on an element.
5. ng-if: Conditionally displays an element based on an expression.

6. What are the string and number expressions?


In AngularJS, string and number expressions are used to interpolate dynamic data
into HTML templates. String expressions are used to display dynamic text, while
number expressions are used to display dynamic numeric values.

String expressions are enclosed in double curly braces "{{ }}" and can contain
AngularJS expressions, variables, functions, and operators. For example, to display
the value of a string variable named "name" in an HTML template,

Number expressions are similar to string expressions, but are used to display
dynamic numeric values. They can also include operators, functions, and
variables, and are enclosed in double curly braces "{{ }}" like string expressions.
For example, to display the sum of two numeric values in an HTML template,
Module 6:

1. Use of Filters and explain any 5 filters.

To use a filter in AngularJS, you simply add the filter name to an expression
using the pipe "|" symbol, followed by any parameters that the filter requires.
For example, to use the built-in "uppercase" filter to convert a string to
uppercase,
Date, currency, limitTo, orderBy, lowercase/uppercase
2. Conditional Directives
Conditional directives are a type of directive in AngularJS that allow
developers to conditionally show or hide elements in the UI based on a
certain condition. These directives are useful for building dynamic,
data-driven web applications, where certain elements may need to be
displayed or hidden based on user input or other factors.
ng-if: This directive conditionally shows or hides an element based on a
boolean expression. If the expression evaluates to true, the element is shown.
ng-show/ng-hide: These directives conditionally show or hide an element
based on a boolean expression. If the expression evaluates to true, the
element is shown using the "ng-show" directive.
ng-switch: This directive conditionally shows one element from a set of
elements, based on a given value. Each element is associated with a specific
value, and the element corresponding to the current value is shown, while the
others are hidden
3. Styles Directives
In AngularJS, directives are used to extend the HTML syntax with new behavior and
functionality. One type of directive is the "style" directive, which is used to
manipulate the styling of HTML elements in the view.
The ng-style directive is used to dynamically set the style of an HTML element based
on an expression in the controller's $scope object.

he ng-class directive is used to dynamically set the CSS class of an HTML element
based on an expression in the controller's $scope object.

4. Angular JS built-in directives: app, init, model

1. ng-app directive:

The ng-app directive is used to define the root element of an AngularJS application. This

directive initializes the AngularJS application and tells AngularJS which part of the HTML

should be compiled and linked with the AngularJS application.

2. ng-init directive:

The ng-init directive is used to initialize values in the controller's $scope object. This directive

evaluates an expression and assigns the result to a variable in the $scope object.

3. ng-model directive:

The ng-model directive is used to bind an HTML element (such as an input field) to a property

in the controller's $scope object. This directive creates a two-way binding between the HTML

element and the $scope object, so changes to the HTML element are automatically reflected

in the $scope object and vice versa.

There are many other built-in directives in AngularJS, such as ng-repeat, ng-click, ng-show,

ng-hide, and many more. These directives are used to add functionality and behavior to

HTML elements in the view and are an essential part of building dynamic and interactive

web applications using AngularJS.


Module 7:
1. What is Controller?
In AngularJS, a controller is a JavaScript constructor function that is used to
define the behavior and data of a specific part of an application. Controllers
are responsible for handling user input, updating the view, and
communicating with the model.
2. What is scope object? Why to use it?
In AngularJS, the $scope object is a special object that serves as the glue between
the view and the controller. It is used to share data between the controller and the
view and to handle events and actions in the view.

1. Share data between controller and view:

The $scope object is used to share data between the controller and the view. Data
can be defined on the $scope object in the controller, and then accessed and
displayed in the view using expressions or directives.

4. Detect changes and update the view:

The $scope object also provides a mechanism for detecting changes in the data and
updating the view accordingly. AngularJS uses a process called "digest cycle" to
monitor the $scope object and update the view when changes are detected.

3. Array members in controller scope


In AngularJS, you can define an array as a member of a controller's $scope object.
This allows you to store and manipulate an array of data in the controller and
display it in the view using directives or expressions.

Module 8:

1. What is use of SPA and Application

SPA stands for Single-Page Application, which is a type of web application that loads
and interacts with a single web page. The content of the page is dynamically updated
as the user interacts with the application, without requiring a full page reload. The
primary benefit of SPAs is that they provide a faster and more responsive user
experience, as well as improved performance since the server only needs to send
data rather than full pages.
SPAs can be used to create fast, responsive web applications that provide a seamless
user experience. Applications, on the other hand, can be used to perform a wide range
of tasks and functions, depending on their specific purpose and design

2. Advantages of SPA.

1. Fast and responsive user experience: SPAs can provide a faster and more
responsive user experience since the server only needs to send data rather
than full pages. This means that the page content can be updated
dynamically without requiring a full page reload, which can significantly
improve the user experience.
2. Better scalability: SPAs can be more scalable compared to multi-page
applications since they can handle a larger volume of users with fewer server
resources. This is because the server only needs to send data and handle
requests, rather than generating and rendering full pages

3. Validation in Angular JS
In AngularJS, validation can be achieved using the built-in ng-model directive and the
ng-valid, ng-invalid, and ng-dirty classes.

1.Add the ng-model directive to your form elements. This directive binds the value of
the form element to a variable in the controller
2.Use the ng-show directive to show error messages when the field is invalid.

4. How to create custom validations?

1. Create a new directive using the directive method of your AngularJS module:
2. we create a directive named customValidation, which requires the ngModel
controller. The link function is called when the directive is linked to an element.
We define a new validator named customValidation that takes the input value as
its argument and returns true or false based on the validation result.
3. we apply the custom-validation directive to an input element. The ng-model
directive is used to bind the input value to a variable in the scope.

5. Use of route provider


In AngularJS, the $routeProvider service is used to define the routes for an application. It
is part of the ngRoute module, which provides routing functionality to AngularJS.

You might also like