AIT Questionnaire
AIT Questionnaire
AIT Questionnaire
a. Core Modules
b. local Modules
c. Third-party Modules
a) Core Modules: Node.js has many built-in modules that are part of the
platform and come with Node.js installation. These modules can be loaded
into the program by using the required function.
Syntax:
const module = require('module_name');
b) Local Modules: Unlike built-in and external modules, local modules are
created locally in your Node.js application. Let’s create a simple calculating
module that calculates various operations. Create a calc.js file that has the
following code:
Ex.
exports.add = function (x, y) {
return x + y;
};
<div *ngIf="isShow">
<h1>Welcome to Angular!</h1>
</div>
<div [ngSwitch]="color">
</div>
// app.component.ts
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
toggle() {
this.isShow = !this.isShow;
setColor(selectedColor: string) {
this.color = selectedColor;
Q.4) Write a program to read the query string using url property in Node
js.
const http = require('http');
res.write('Query String:\n');
res.write(JSON.stringify(query));
res.end();
});
server.listen(PORT, () => {
});
Installing NPM:
To install NPM, it is required to install Node.js as NPM gets installed with
Node.js automatically.
<div>
<h1>Welcome to My Angular App!</h1>
<app-custom-directive></app-custom-directive></div>
// app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent { }
@Directive({
selector: '[appCustomDirective]'
})
export class CustomDirective {
constructor(private el: ElementRef) {
el.nativeElement.style.color = 'blue';
el.nativeElement.style.fontWeight = 'bold';
}
}
In this example:
We have an Angular component defined in app.component.ts and its
template in app.component.html.
The component template uses a custom directive app-custom-directive.
The custom directive CustomDirective is defined in custom.directive.ts, which
changes the style of the element to which it is applied. In this case, it changes
the text color to blue and makes it bold.
You can include these files in your Angular project to see the effect of the
custom directive on the component's template.
Q7) What are the Typesoript components
1. Language Components:
o These include TypeScript language elements such
as syntax, keywords, and type annotations.
o They define the building blocks of TypeScript code.
2. The TypeScript Compiler (TSC):
o The TSC transforms TypeScript programs into equivalent
JavaScript code.
o It performs parsing and type checking to ensure correctness.
o Since browsers can’t execute TypeScript directly, TSC compiles
it to JavaScript.
o To compile TypeScript, use the tsc command in the terminal.
o The tsconfig.json file specifies compiler options and
configuration.
3. Declaration Files (.d.ts):
o When you compile TypeScript, it can generate a .d.ts file.
o This file acts as an interface to the components in the compiled
JavaScript.
o It provides IntelliSense for JavaScript libraries like jQuery.
4. The TypeScript Language Services:
o These services enhance editors and tools.
o Features include code
formatting, outlining, colorization, statement completion, and
more.
Q8) Write a program using NPM which will convert entered string into
lower case & upper case
// Get the user input (you can use any method to get input)
<html>
<head>
<title>Canvas Example</title>
</head>
<body>
<h1>Blue Circle</h1>
<script>
ctx.beginPath();
ctx.fillStyle = 'blue';
ctx.fill();
</script>
</body>
</html>
Q10) Write a PHP script to demonstrate variables in PHP. Use Globals,
local & global keyword to access variables.
<?php
// Global variable
$globalVar = "I am global!";
function demonstrateVariables() {
// Local variable
$localVar = "I am local!";
1. <section> Element:
o Defines a thematic grouping of content.
o Often used for chapters, introduction, news items, or contact information.
o Example:
o <section>
o <h1>WWF</h1>
o <p>The World Wide Fund for Nature (WWF) is an international
organization...</p>
o </section>
2. <article> Element:
o Specifies independent, self-contained content.
o Should make sense on its own and can be distributed independently.
o Used for forum posts, blog articles, user comments, etc.
o Example:
o <article>
o <h2>Google Chrome</h2>
o <p>Google Chrome is a web browser developed by
Google...</p>
o </article>
3. <header> and <footer> Elements:
o <header> represents introductory content or a container for site-wide information.
o <footer> represents the footer of a section or the entire page.
o Example:
o <header>
o <h1>Welcome to My Website</h1>
o </header>
o <footer>
o <p>Contact: info@example.com</p>
o </footer>
4. <nav> Element:
o Defines navigation links.
o Typically used for menus, navigation bars, or site maps.
o Example:
o <nav>
o <ul>
o <li><a href="/">Home</a></li>
o <li><a href="/about">About</a></li>
o </ul>
o </nav>
5. <main> Element:
o Represents the main content of a document.
o There should be only one <main> per page.
o Example:
o <main>
o <h1>Featured Article</h1>
o <p>...</p>
o </main>
// Arithmetic operators
$x = 20;
$y = 10;
// Assignment operators
$a = 5;
$b = 3;
$a += $b; // Equivalent to $a = $a + $b
// Comparison operators
$p = 10;
$q = 20;
echo "Is \$p equal to \$q? " . ($p == $q) . "<br>"; // false
echo "Is \$p not equal to \$q? " . ($p != $q) . "<br>"; // true
echo "Is \$p greater than \$q? " . ($p > $q) . "<br>"; // false
// Logical operators
$isTrue = true;
$isFalse = false;
?>
1. Purpose:
o var_dump() provides detailed information about a variable, including its type and
value.
o It’s particularly useful during development and debugging to understand the
contents of variables.
2. Syntax:
3. var_dump(variable1, variable2, ...);
4. Parameters:
o You can pass one or more variables (separated by commas) to var_dump() for
inspection.
o It accepts any type of variable: integers, strings, arrays, objects, etc.
5. Example:
6. <?php
7. $a = 32;
8. $b = "Hello, world!";
9. $c = 32.5;
10. $d = array("red", "green", "blue");
11.
12. // Dump information about different variables
13. echo var_dump($a) . "<br>";
14. echo var_dump($b) . "<br>";
15. echo var_dump($c) . "<br>";
16. echo var_dump($d) . "<br>";
17.
18. // Dump two variables
19. echo var_dump($a, $b) . "<br>";
20. ?>
Output:
int(32)
string(13) "Hello, world!"
float(32.5)
array(3) {
[0]=> string(3) "red"
[1]=> string(5) "green"
[2]=> string(4) "blue"
}
int(32) string(13) "Hello, world!"
In this example:
1. Element Selector:
o The most basic selector.
o Selects HTML elements based on their element name.
o Example:
o p {
o color: blue;
o font-size: 16px;
o }
This will style all <p> elements with blue text and a font size of 16 pixels.
2. ID Selector:
o Selects an element based on its unique ID attribute.
o Use the # symbol followed by the ID name.
o Example:
o #my-heading {
o font-weight: bold;
o }
This will style the element with id="my-heading" by making its text bold.
3. Class Selector:
o Selects elements with a specific class attribute.
o Use the . symbol followed by the class name.
o Example:
o .highlight {
o background-color: yellow;
o }
This will style all elements with class="highlight" by giving them a yellow
background.
4. Universal Selector:
o Selects all HTML elements on the page.
o Use the * symbol.
o Example:
o * {
o margin: 0;
o padding: 0;
o }
5. Grouping Selector:
o Combines multiple selectors into one rule.
o Separate selectors with a comma.
o Example:
o h1, h2, h3 {
o color: purple;
o }
This will style all <h1>, <h2>, and <h3> elements with purple text.
6. Descendant Selector:
o Selects an element that is a descendant of another element.
o Use a space between the parent and child elements.
o Example:
o article p {
o font-style: italic;
o }
This will style all <p> elements inside an <article> with italic font.
Q15) Write a PHP script to disply employees belongs to IT department
and salary is in between 30, 000 – 80, 000 and store found records into
another table. [6] (Assume suitable table structure)
<?php
// Retrieve employees from the IT department with salaries in the specified range
$sql = "SELECT * FROM employees WHERE department = 'IT' AND salary BETWEEN 30000
AND 80000";
if ($result) {
$newTableName = 'filtered_employees';
name VARCHAR(255),
city VARCHAR(255),
salary DECIMAL(10, 2)
)";
mysqli_query($conn, $createTableSql);
mysqli_query($conn, $insertSql);
}
echo "Filtered records have been stored in the table '$newTableName'.";
} else {
mysqli_close($conn);
?>
Q16) What is CSS framework? What are the different sorts of css
framework?
A CSS framework is a pre-prepared library that contains different styles and templates. It
helps standardize the process of designing and developing web pages by providing ready-to-
use components. Here are some key points about CSS frameworks:
1. Advantages:
o Efficiency: Writing CSS from scratch can be time-consuming. CSS frameworks offer
pre-designed components, saving development time.
o Responsive Design: Many frameworks include built-in responsive features for
adapting layouts to various screen sizes.
o Cross-Browser Compatibility: Frameworks are tested across browsers, reducing
debugging efforts.
o Community Support: Popular frameworks have active communities, providing
resources and updates.
2. Types of CSS Frameworks:
o Bootstrap: Widely used, feature-rich, and mobile-first. Provides a grid system,
components, and utilities.
o Tailwind CSS: Utility-first framework with customizable classes. Ideal for rapid
development.
o Material UI: Implements Google’s Material Design. Offers components and theming.
o styled-components: Allows writing CSS in JavaScript. Popular in React projects.
o Foundation: Responsive framework with a modular approach.
o Chakra UI: Component library for React with emphasis on accessibility.
o Emotion: CSS-in-JS library for styling React components.
o Bulma: Lightweight and easy-to-use framework.
o Pure CSS: Minimalistic framework with basic styling.
Q17) Write a PHP script & insert at least 5 records into it & update
specific record in database. Assume student table with required fields in
database.
<?php
$host = 'localhost';
$username = 'your_username';
$password = 'your_password';
$dbname = 'your_database';
// Create a connection
if (!$conn) {
$students = [
];
foreach ($students as $student) {
mysqli_query($conn, $sql);
$updatedAge = 23;
mysqli_query($conn, $sqlUpdate);
mysqli_close($conn);
?>
CSS saves a lot of work. It can control the layout of multiple web pages all
at once.
1. Inline CSS:
o Applied directly to individual HTML elements using the style attribute within the
HTML tag.
o Overrides any external or internal styles.
o Example:
2. <p style="color: #009900; font-size: 20px;">GeeksForGeeks</p>
3. Internal or Embedded CSS:
o Defined within the HTML document’s <style> element in the <head> section.
o Applies styles to specified HTML elements.
o Example:
4. <style>
5. .main {
6. text-align: center;
7. }
8. .GFG {
9. color: #009900;
10. font-size: 50px;
11. }
12. #geeks {
13. font-size: 25px;
14. color: skyblue;
15. }
16. </style>
17. External CSS:
o Contains separate CSS files with a .css extension.
o Linked to the HTML document using the <link> element in the <head> section.
o Styles multiple HTML pages with a single style sheet.
o Example:
18. <!-- In the HTML file -->
19. <link rel="stylesheet" href="styles.css">
20.
21. <!-- In the external CSS file (styles.css) -->
22. .main {
23. text-align: center;
24. }
25. .GFG {
26. font-size: 60px;
27. color: green;
28. }
29. #geeks {
30. font-size: 25px;
31. color: skyblue;
32. }
Q19) Write a program using tag to draw line, rectangle and triangle
shapes.
example of an SVG program that draws a line, a rectangle, and a triangle shape using the
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>SVG Shapes</title>
</head>
<body>
</svg>
</body>
</html>
Explanation:
• The <svg> element defines the SVG canvas with a specified width and height.
• The <line> element draws a line from (50,20) to (250,20) with a black stroke.
• The <rect> element creates a blue rectangle with top-left corner at (50,50) and
dimensions 200x100.
• The <polygon> element draws a green triangle with vertices at (150,150), (50,250),
and (250,250).
Q20)
`<video>` tag along with its commonly used properties and attributes:
4. **loop**: When present, the video will loop and play again from the
beginning once it reaches the end.
6. **preload**: Specifies how the video should be loaded when the page
loads. Possible values are "auto", "metadata", and "none".
<html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Video Example</title>
</head>
<body>
</video>
</body>
</html>
Q21) Write CSS for paragraph tag: border 1. color-blue, font size-20,
font name- arial, padding 50px.
p{
font-size: 20px;
padding: 50px;
Working of Node.js:
Features of Node.js:
2. **High Performance**: Node.js is known for its high performance and low
latency. By using asynchronous I/O operations and the event loop, Node.js
can handle I/O-bound tasks efficiently, making it suitable for building real-
time applications and APIs.
6. **Use Cases**: Node.js is well-suited for building web servers, APIs, real-
time applications (such as chat applications and online gaming platforms),
streaming applications, and microservices architectures.
const fs = require('fs');
fs.unlinkSync(filename);
<ul>
</ul>
// app.component.ts
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
Explanation:
In app.component.html, we use the *ngFor directive to iterate over the names array.
For each name in the array, an <li> element is created within the <ul>.
Q25) What is data binding in Angular? Explain with example.
Data binding in Angular is a powerful feature that allows you to connect and synchronize
data between the model (component) and the view (HTML template). It ensures that any
changes in the model automatically update the view, and vice versa. There are several types
of data binding in Angular:
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
username = 'John';
changeUsername() {
this.username = 'Alice';
}
}
Explanation:
• We use interpolation ({{ }}) to bind the username property to the view.
• Initially, the view displays “Welcome, John.”
• When the button is clicked, the changeUsername() method updates the username, and
the view reflects the change.
Q26) What is an associative array in PHP? Explain with example.
An associative array in PHP is an array where each element is associated with a specific key
(also known as an index or name) instead of a numerical index. These keys can be strings or
integers, allowing you to create a mapping between keys and values. Associative arrays are
useful for representing data with named attributes or properties.
Here’s an example of how to create and use an associative array in PHP:
<?php
// Create an associative array
$student = array(
'name' => 'John Doe',
'age' => 20,
'major' => 'Computer Science',
'gpa' => 3.5
);
Q27) Write a PHP script to design a form for exam registration. Insert 5
records in database and display all the inserted records on new page.
(Assume suitable table structure)
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "exam_registration";
if ($conn->connect_error) {
$conn->close();
?>
Q29) Explain all array sorting methods in PHP with suitable example.
1. sort():
o Sorts an array in ascending order (from smallest to largest).
o Re-indexes the array keys.
o Example:
2. $numbers = array(4, 6, 2, 22, 11);
3. sort($numbers);
4. print_r($numbers);
Output:
Array
(
[0] => 2
[1] => 4
[2] => 6
[3] => 11
[4] => 22
)
5. rsort():
o Sorts an array in descending order (from largest to smallest).
o Re-indexes the array keys.
o Example:
6. $numbers = array(4, 6, 2, 22, 11);
7. rsort($numbers);
8. print_r($numbers);
Output:
Array
(
[0] => 22
[1] => 11
[2] => 6
[3] => 4
[4] => 2
)
9. asort():
o Sorts an associative array in ascending order based on the values.
o Maintains the association between keys and values.
o Example:
10. $age = array(
11. 'Peter' => 35,
12. 'Ben' => 37,
13. 'Joe' => 43
14. );
15. asort($age);
16. print_r($age);
Output:
Array
(
[Peter] => 35
[Ben] => 37
[Joe] => 43
)
17. ksort():
o Sorts an associative array in ascending order based on the keys.
o Maintains the association between keys and values.
o Example:
18. $age = array(
19. 'Peter' => 35,
20. 'Ben' => 37,
21. 'Joe' => 43
22. );
23. ksort($age);
24. print_r($age);
Output:
Array
(
[Ben] => 37
[Joe] => 43
[Peter] => 35
)
25. arsort():
o Sorts an associative array in descending order based on the values.
o Maintains the association between keys and values.
o Example:
26. $age = array(
27. 'Peter' => 35,
28. 'Ben' => 37,
29. 'Joe' => 43
30. );
31. arsort($age);
32. print_r($age);
Output:
Array
(
[Joe] => 43
[Ben] => 37
[Peter] => 35
)
33. krsort():
o Sorts an associative array in descending order based on the keys.
o Maintains the association between keys and values.
o Example:
34. $age = array(
35. 'Peter' => 35,
36. 'Ben' => 37,
37. 'Joe' => 43
38. );
39. krsort($age);
40. print_r($age);
Output:
Array
(
[Peter] => 35
[Joe] => 43
[Ben] => 37
)
Q30) Create a login form, both username & password fields are
mandatory, after entering the values transfer user control to next web
page showing message as “You have login successfully”. (Use ng-href &
ng-required).
<html>
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<title>Login Form</title>
<script
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js"></s
cript>
</head>
<body ng-controller="loginController">
<h1>Login Form</h1>
<form ng-submit="login()">
<label for="username">Username:</label><br>
<label for="password">Password:</label><br>
</form>
<script>
$scope.login = function() {
$window.location.href = 'success.html';
} else {
};
});
</script>
</body>
</html>
Q31) What is HTML5. Explain its features and advantages
HTML5 is the latest version of Hypertext Markup Language, the standard language used to create
and design web pages. It introduces several new elements, attributes, and APIs that enhance the
capabilities of web development. Here are some of the key features and advantages of HTML5:
2. **Audio and Video Support**: HTML5 includes built-in support for embedding audio and video
content directly into web pages using the `<audio>` and `<video>` elements, eliminating the
need for third-party plugins like Flash.
3. **Canvas and SVG**: HTML5 introduces the `<canvas>` element for drawing graphics and
animations using JavaScript, providing a powerful and flexible way to create interactive content. It
also supports Scalable Vector Graphics (SVG) for creating vector-based graphics directly within
HTML documents.
4. **Form Enhancements**: HTML5 introduces several new input types, attributes, and validation
features for forms, making it easier to create user-friendly and accessible forms without relying on
JavaScript or third-party libraries. Examples include `type="email"`, `type="date"`,
`type="number"`, `required`, `pattern`, etc.
5. **Local Storage**: HTML5 provides support for client-side storage through the `localStorage`
and `sessionStorage` APIs, allowing web applications to store data locally on the user's device,
even after the browser is closed.
6. **Geolocation**: HTML5 includes a Geolocation API that enables web applications to access the
user's geographic location information, allowing for location-based services and personalized
experiences.
7. **Web Workers**: HTML5 introduces the concept of Web Workers, which allows scripts to run
in the background without blocking the main page's execution, enabling multi -threaded JavaScript
execution for improved performance and responsiveness.
8. **Offline Applications**: HTML5 includes features such as the Application Cache (AppCache)
and Service Workers, which enable web applications to work offline and provide a better user
experience in low-connectivity or offline scenarios.
2. **Improved Multimedia Support**: With native support for audio, video, and graphics, HTML5
eliminates the need for third-party plugins like Flash, reducing compatibility issues, security
vulnerabilities, and performance overhead.
4. **Better Performance**: HTML5's canvas element and Web Workers enable developers to
create high-performance, interactive web applications with smoother animations, faster rendering,
and improved responsiveness.
6. **Easier Development**: HTML5's new features and APIs simplify common web development
tasks such as form validation, multimedia embedding, and client-side storage, reducing the need
for external libraries and frameworks and streamlining the development process.
Q32) What are the objectives of CSS architecture
The objectives of CSS architecture are to provide a systematic and organized approach to styling
web applications, ensuring consistency, maintainability, scalability, and performance. Here are the
main objectives of CSS architecture:
1. **Consistency**: CSS architecture aims to establish consistent styling patterns and conventions
across a web application, ensuring that elements and components have a cohesive look and feel.
3. **Scalability**: CSS architecture helps manage the complexity of styling large -scale
applications by providing guidelines and best practices for organizing stylesheets, avoiding global
styles, and encapsulating styles within components. This makes it easier to scale the application
as it grows and evolves over time.
6. **Accessibility**: CSS architecture should consider accessibility requirements and ensure that
styles are applied in a way that enhances usability and accessibility for users with disabilities. This
includes using semantic HTML elements, providing high contrast colors, and ensuring keyboard
navigation and screen reader compatibility.
7. **Browser Compatibility**: CSS architecture should take into account cross -browser
compatibility issues and provide strategies for dealing with browser-specific quirks and
inconsistencies. This may involve using vendor prefixes, feature detection, or po lyfills to ensure
consistent rendering across different browsers and devices.
Q33) What is Define function in PHP
In PHP, the `define()` function is used to define a constant. A constant is a variable that cannot be
changed or redefined once it has been declared. Constants are useful for defining values that
remain the same throughout the execution of a script.
- `case_insensitive` (optional): Specifies whether the constant name should be case -insensitive.
By default, it is set to false.
define("PI", 3.14);
we define a constant named "PI" with a value of 3.14. Once defined, the constant can be accessed
throughout the script using its name.
Constants are typically used for values that are not expected to change during the execution of the
script, such as configuration settings, mathematical constants, or error codes.
Q34) Write a program for multiplication of 2 numbers using event handling in node. js. Call
multiplication function as an event call
});
emitter.emit('multiply', 5, 10);
In PHP, both cookies and sessions are mechanisms used to maintain state information between
HTTP requests, but they work in slightly different ways:
### Cookies:
- **Definition**: Cookies are small pieces of data stored on the client's browser. They are sent with
every HTTP request to the server, allowing the server to read and modify them.
- **Usage**: Cookies are commonly used for storing user-specific information, such as login
credentials, shopping cart items, user preferences, etc.
- **Setting Cookies**: Cookies are set using the `setcookie()` function in PHP. For example:
This code sets a cookie named "username" with the value "John" that expires in 30 days.
- **Accessing Cookies**: Cookies are accessible through the `$_COOKIE` superglobal array in
PHP. For example:
echo $_COOKIE['username'];
### Sessions:
- **Definition**: Sessions are a server-side mechanism for storing and managing user-specific
data. Unlike cookies, session data is stored on the server, and only a session ID is sent to the
client's browser.
- **Usage**: Sessions are commonly used for maintaining user authentication, storing user-specific
data during a browsing session, and managing state information across multiple page requests.
- **Starting a Session**: Sessions are started using the `session_start()` function in PHP. For
example:
session_start();
- **Storing Session Data**: Session data is stored in the `$_SESSION` superglobal array in PHP.
For example:
$_SESSION['username'] = 'John';
- **Accessing Session Data**: Session data can be accessed throughout the session using the
`$_SESSION` superglobal array. For example:
echo $_SESSION['username'];
session_destroy();
This will destroy all session data associated with the current session.
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: