NodeJs Lab Viva Questions & Answers
NodeJs Lab Viva Questions & Answers
A: The <video> tag is used to embed video content in a web page. It supports multiple video formats
A: The <audio> tag is used to embed sound content in a web page. It supports audio formats like
A: SVG stands for Scalable Vector Graphics. It is used to define vector-based graphics for the web
A: Web Storage provides two mechanisms for storing data on the client side: localStorage and
sessionStorage.
A: Drag and Drop is a feature that allows users to drag items from one location and drop them into
A: The Geolocation API allows the user to share their location with web applications, typically using
A: CSS (Cascading Style Sheets) is used to style and layout web pages, including colors, fonts, and
spacing.
Q: What is Bootstrap?
A: Bootstrap is a front-end framework for developing responsive and mobile-first websites using
HTML, CSS, and JavaScript components.
A: You can set up Bootstrap by including its CSS and JS files via a CDN or by downloading and
A: Bootstrap Templates are pre-designed web pages or components built using Bootstrap that help
speed up development.
Q: What is Git?
A: Git is a distributed version control system used to track changes in source code during software
development.
A: You start by installing Git and setting up user credentials using commands like 'git config --global
A: You can create a local repository using 'git init', then track changes with 'git add' and 'git commit'.
A: Branches in Git are used to develop features, fix bugs, or experiment independently from the
main codebase.
A: You merge branches using the 'git merge' command, which combines changes from different
branches.
A: You connect to a remote repository using 'git remote add', then use 'git push' and 'git pull' to sync
changes.
JavaScript and jQuery Viva Questions and Answers
A: Variables are containers for storing data values. They can be declared using var, let, or const.
A: Arrays are used to store multiple values in a single variable. They are defined using square
brackets [].
A: Objects are collections of key-value pairs used to store multiple related values.
A: Loops are used to execute a block of code multiple times. Common loops include for, while, and
do-while.
A: Conditionals (if, else if, else) are used to perform different actions based on different conditions.
A: A switch statement is used to perform different actions based on different values of a variable.
A: Functions are blocks of code designed to perform a particular task and can be reused.
A: Events are actions that occur in the browser, like clicks or key presses, which can be handled
A: Form validation ensures that user input is correct before it is sent to the server.
A: jQuery selectors are used to select and manipulate HTML elements based on their name, id,
A: Mouse events in jQuery include click, dblclick, mouseenter, mouseleave, etc., to respond to user
interactions.
A: Form events include focus, blur, change, submit, and are used to handle user interactions with
forms.
A: DOM manipulation involves changing the content, structure, or style of elements in the document
A: jQuery provides methods like show, hide, fadeIn, fadeOut, slideUp, and slideDown for adding
visual effects.
A: Traversing and filtering involve navigating and refining selections in the DOM using methods like
1. What is Node.js?
Node.js is a runtime environment that allows you to run JavaScript code outside of a browser. It is
built on Chrome's V8 JavaScript engine and is designed for building scalable network applications.
Node.js can be installed from the official website (https://nodejs.org/) or using a version manager
like nvm (Node Version Manager). Installation provides both the Node.js runtime and npm (Node
Package Manager).
You can create a simple server using the built-in http module. Example:
const http = require('http');
const server = http.createServer((req, res) => {
res.write('Hello World');
res.end();
});
server.listen(3000);
A simple Node.js project might include creating a basic server that handles HTTP requests and serves
static content or processes form data.
5. What is Express.js?
Express.js is a minimal and flexible Node.js web application framework that provides features for
building web and mobile applications, such as routing, middleware support, and template engines.
app.listen(3000);
Middleware functions are functions that have access to the request and response objects and the
next middleware function. They are used to execute code, modify requests/responses, and end
request-response cycles.
Password encryption is typically done using libraries like bcrypt to hash passwords before storing
them in a database. This enhances security by not storing raw passwords.
9. How is login functionality implemented in Node.js?
Login involves verifying user credentials by comparing entered passwords with hashed passwords in
the database and managing user sessions or tokens for authentication.
JWT (JSON Web Token) is used for securely transmitting information between parties as a JSON
object. It is commonly used for authentication in Node.js applications by encoding user information
and verifying it on each request.
• Navigate into the project folder and run ng serve to start the development server.
• A template (HTML)
• A stylesheet (CSS)
• A class (TypeScript)
• Property binding: Used to bind data from the component class to the template.
<div [innerText]="message"></div>
Event binding: Used to bind events from the template to methods in the component class.
<button (click)="submitData()">Submit</button>
6. What is ngModel and how does it work with two-way data binding?
ngModel is used for two-way data binding in Angular. It synchronizes the data between the
component and the view. Changes made in the view are reflected in the component and vice versa.
<input [(ngModel)]="name">
<p>{{name}}</p>
7. How do you fetch data from a service in Angular?
To fetch data from a service, first create a service using the Angular CLI:
ng generate service data
Then, inject the service into the component and use HttpClient to fetch data. Example:
import { Component, OnInit } from '@angular/core';
import { DataService } from './data.service';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
data: any;
ngOnInit() {
this.dataService.getData().subscribe((response) => {
this.data = response;
});
}
}
In the component:
this.dataService.submitData(formData).subscribe(response => {
console.log('Data submitted', response);
});
@NgModule({
imports: [HttpClientModule]
})
export class AppModule {}
10. What are observables and how are they used in Angular?
Observables are used in Angular to handle asynchronous data streams. An observable emits values
over time and can be subscribed to, which makes it ideal for handling HTTP responses, form inputs,
or events.
import { Observable } from 'rxjs';
this.http.get('https://example.com/data').subscribe(data => {
console.log(data);
});
React JS is a JavaScript library for building user interfaces, developed and maintained by Facebook. It
enables the development of single-page applications with a component-based architecture, where
each component manages its own state and UI.
To install React JS, you need to have Node.js and npm (Node Package Manager) installed on your
system. Once installed, you can create a new React app by running:
npx create-react-app my-app
cd my-app
npm start
create-react-app is a command-line tool that sets up a new React project with a pre-configured
development environment. It includes configuration for Webpack, Babel, and other dependencies, so
developers can focus on writing code without worrying about build configurations.
React Router is a library used for routing in React applications. It allows you to navigate between
different components or views in a single-page application without reloading the page. You can
install React Router with:
npm install react-router-dom
To use React Router, you define routes and associate them with components. Example:
import { BrowserRouter as Router, Route, Switch } from 'react-
router-dom';
import Home from './Home';
import About from './About';
function App() {
return (
<Router>
<Switch>
<Route path="/home" component={Home} />
<Route path="/about" component={About} />
</Switch>
</Router>
);
}
React Components are the building blocks of a React application. They can be functional or class-
based, and they return JSX (a syntax extension for JavaScript that looks similar to HTML) to define the
structure and behavior of the UI. Components can manage state, receive inputs via props, and
handle user interactions.
Example:
const [count, setCount] = useState(0);
Props: Props (short for properties) are used to pass data from a parent component to a child
component. Props are immutable and cannot be modified by the child component.
Example:
<ChildComponent message="Hello" />
In React, you can handle forms using controlled components, where the form element’s value is
controlled by the component's state. You can set the value property of an input field to the state and
handle the input changes with an event handler.
Example:
function Form() {
const [name, setName] = useState('');
return (
<form onSubmit={handleSubmit}>
<input
type="text"
value={name}
onChange={(e) => setName(e.target.value)}
/>
<button type="submit">Submit</button>
</form>
);
}
1. Mounting: When a component is created and inserted into the DOM (e.g., constructor,
render, componentDidMount).
Class components have life-cycle methods, while functional components use hooks like useEffect to
handle side-effects.
9. What is React Redux?
Redux is a state management library for JavaScript applications, often used with React. It provides a
centralized store for the application’s state and allows components to access the state through
actions and reducers. Redux follows a unidirectional data flow: Actions -> Reducers -> Store ->
Components.
• Learning Curve: Angular has a steeper learning curve due to its complex architecture and
more concepts to understand. React is more beginner-friendly with a simpler API and less
opinionated design.
• Data Binding: Angular uses two-way data binding, whereas React uses one-way data binding.
• State Management: React relies on third-party libraries (like Redux or Context API) for state
management, whereas Angular has built-in services for managing state.
• Performance: React typically offers better performance due to its virtual DOM, which
minimizes the number of updates to the real DOM.