0% found this document useful (0 votes)
25 views9 pages

Web Technology Viva

Uploaded by

taskeenafifa934
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views9 pages

Web Technology Viva

Uploaded by

taskeenafifa934
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

1. What is HTML?

HTML (Hypertext Markup Language) is the standard markup language used to create web pages.
It describes the structure of web pages using a system of tags or elements such as <html>,
<head>, <body>, <title>, etc. HTML defines the content and structure, but it doesn't handle the
design or interactivity.

2. What is the purpose of the <head> and <body> tags in HTML?

 <head>: Contains meta-information about the HTML document, such as the title of the
document, links to stylesheets, and other meta tags like <meta>, <link>, and <script>. It
does not display content on the web page itself.
 <body>: Contains the main content of the HTML document, such as text, images, links,
tables, and other elements that are visible to users.

3. What are CSS selectors?


CSS selectors are patterns used to select and style HTML elements. They define which HTML
elements are to be styled. Common selectors include:

 Element Selector: Targets elements by tag name (e.g., p, h1).


 Class Selector: Targets elements by class (e.g., .className).
 ID Selector: Targets elements by ID (e.g., #idName).
 Attribute Selector: Targets elements with a specific attribute (e.g., [type="text"]).

4. Explain the box model in CSS.


The CSS box model defines the rectangular structure of an element, consisting of the following
parts:

 Content: The actual content of the element, such as text or images.


 Padding: The space between the content and the border.
 Border: A line around the padding (optional).
 Margin: The space between the element's border and surrounding elements.

The total width and height of an element are calculated by adding the content, padding, border,
and margin.

5. What is JavaScript and how is it different from Java?


JavaScript is a high-level, interpreted scripting language used to create interactive effects within
web browsers. It is primarily used for client-side scripting on web pages.
Difference from Java:

 JavaScript is a dynamic, weakly typed language used mainly for web development
(client-side scripting).
 Java is a compiled, object-oriented programming language used for building
applications, desktop software, and web services (server-side).
6. What are functions in JavaScript?A function in JavaScript is a block of code designed to
perform a particular task. Functions are reusable and can be called with arguments to return a
result. A basic function is defined using the function keyword:

javascript
function greet(name) {
return "Hello, " + name;
}

7. Explain the concept of DOM in JavaScript.


DOM (Document Object Model) is a programming interface for web documents. It represents
the structure of the document as a tree of objects. JavaScript can interact with the DOM to
dynamically change the content, structure, and style of a web page. Each HTML element is
represented as an object, and JavaScript can modify these objects through methods like
getElementById(), querySelector(), etc.

8. What is AJAX and how does it work?


AJAX (Asynchronous JavaScript and XML) is a technique used in web development to create
asynchronous web applications. It allows web pages to load data in the background without
reloading the entire page. AJAX works by using JavaScript to send HTTP requests to the server
and receive data, which can then be updated in the page without requiring a reload.

9. What is the difference between GET and POST methods in HTTP?

 GET: Sends data to the server in the URL and is used to retrieve data. It is less secure as
the data is visible in the URL and has a size limitation.
 POST: Sends data to the server in the body of the request. It is used to send data (e.g.,
form submissions) and is more secure as the data is not exposed in the URL.

10. What are cookies in web development?


Cookies are small pieces of data that are stored on the client-side (in the user's browser) and can
be used to remember user preferences, session data, and other information. They are sent
between the server and the client in HTTP requests and responses. Cookies can have expiration
dates, and they can be accessed using JavaScript.

11. What is the purpose of the <link> tag in HTML?


The <link> tag is used to link an external resource, such as a stylesheet, to an HTML document.
For example, it is commonly used to link a CSS file to the HTML document:

html
<link rel="stylesheet" href="styles.css">

12. What is the difference between inline and block-level elements in HTML?
 Inline Elements: These elements only take up as much width as necessary and do not
start on a new line. Examples: <span>, <a>, <strong>.
 Block-level Elements: These elements take up the full width available and always start
on a new line. Examples: <div>, <p>, <h1>.

13. What are the different types of positioning in CSS?


CSS provides several ways to position elements:

 Static: Default positioning, elements are placed in the normal document flow.
 Relative: Positioned relative to its normal position in the document flow.
 Absolute: Positioned relative to the nearest positioned ancestor (or the document body if
no ancestor is positioned).
 Fixed: Positioned relative to the viewport, staying in the same place even when scrolling.
 Sticky: Behaves like relative positioning until a certain point in the page, after which it
becomes fixed

14. What is the purpose of the <meta> tag in HTML?The <meta> tag provides metadata
about the HTML document, such as character set, author, description, and keywords. This
information is used by browsers and search engines. For example, a meta tag for setting the
character encoding:

html
<meta charset="UTF-8">

15. What are the types of events in JavaScript?


JavaScript events are actions that occur in the browser, and these events can be captured and
handled by JavaScript. Types of events include:

 Mouse Events: click, mouseover, mouseout, mousedown, mouseup.


 Keyboard Events: keydown, keyup, keypress.
 Form Events: submit, focus, blur.
 Window Events: load, resize, scroll.

16. What is a responsive web design?


Responsive web design is an approach to web development that ensures web pages look good on
all devices (desktops, tablets, smartphones) by using flexible layouts, images, and CSS media
queries. It adjusts the layout and content to the screen size.

17. What is the purpose of a <script> tag in HTML?


The <script> tag is used to define and include JavaScript code in an HTML document. The
JavaScript code can be written directly within the <script> tags or linked to an external .js file:

html
<script src="script.js"></script>
18. What is Bootstrap?
Bootstrap is a popular front-end framework for developing responsive and mobile-first websites.
It provides ready-to-use components like navigation bars, forms, buttons, and grids, along with
CSS and JavaScript-based tools for easier web development.

19. Explain the difference between null and undefined in JavaScript.

 null: Represents an intentional absence of any value or object. It is an object type in


JavaScript.
 undefined: Represents an uninitialized variable or a variable that has been declared but
not assigned a value.

20. What is the difference between HTML and XHTML?

HTML (HyperText Markup Language) is less strict about syntax and allows for
flexibility with certain rules.

XHTML (Extensible Hypertext Markup Language) is a stricter version of HTML that


follows XML rules. Every tag in XHTML must be properly nested and closed, and
attribute values must be quoted.

21. What are the different types of CSS?

Inline CSS: Written directly within an HTML tag using the style attribute.

Internal CSS: Written within the <style> tag inside the <head> section of an HTML
document.

External CSS: Written in a separate .css file, which is linked to the HTML document
using the <link> tag..

22. What are the different data types in JavaScript?

Primitive data types: Number, String, Boolean, Null, Undefined, Symbol (ES6)

Reference data types: Object, Array, Function

23. What is the role of a web server?

A web server is responsible for hosting and delivering web pages to users' browsers.
When a user sends an HTTP request to the server, it processes the request, retrieves the
requested content (such as an HTML page), and sends it back to the client.

24. What is the difference between HTTP and HTTPS?


HTTP: A protocol for transmitting web data without encryption.

HTTPS: A secure version of HTTP, where the data is encrypted using SSL/TLS to ensure
privacy and prevent tampering.

25. What is jQuery?

jQuery is a fast, small, and feature-rich JavaScript library. It simplifies tasks like HTML
document traversal and manipulation, event handling, and animation by providing easy-
to-use methods that work across different web browsers.

26. What is the difference between div and span?

<div>: A block-level element used to group larger sections of content. It creates a new
line before and after the element.

<span>: An inline element used to group smaller portions of content without creating a
line break.

27. What are Web APIs?

Web APIs (Application Programming Interfaces) are interfaces provided by web


browsers that allow JavaScript to interact with the web browser, system, or other
services. Examples include the Geolocation API, Fetch API, and Canvas API.

28. What is the difference between a front-end and a back-end developer?

Front-end developer: Focuses on the visual and interactive aspects of a website (HTML,
CSS, JavaScript).

Back-end developer: Works on the server side, handling database interactions, server
logic, and API creation (using languages like Node.js, Python, PHP).

29. What is a RESTful API?

A RESTful API is an application programming interface that follows the principles of


Representational State Transfer (REST). It uses standard HTTP methods (GET, POST,
PUT, DELETE) and stateless communication to perform operations on resources,
typically in JSON format.

30. What is a CDN (Content Delivery Network)?

A CDN is a network of geographically distributed servers that work together to deliver


web content (like images, CSS files, JavaScript) to users quickly. It reduces latency by
serving content from a server that is physically closer to the user.
31. What is PHP?

PHP (Hypertext Preprocessor) is a widely-used, open-source, server-side scripting


language designed for web development. It is embedded into HTML to create dynamic
web pages. PHP allows you to interact with databases, handle forms, and manage
sessions, making it powerful for building web applications.

32. What is the difference between echo and print in PHP?

 echo: It is a language construct used to output data to the screen. It can take multiple
parameters and does not return a value.
 print: It is also a language construct used for outputting data but returns 1, meaning it
can be used in expressions.

php
echo "Hello, world!"; // Can output multiple values
print "Hello, world!"; // Outputs one value and returns 1

33. What are the different data types in PHP?

PHP supports several data types:

 String: Textual data, e.g., "Hello"


 Integer: Whole numbers, e.g., 25
 Float/Double: Decimal numbers, e.g., 3.14
 Boolean: True or false values, e.g., true or false
 Array: A collection of values, e.g., array(1, 2, 3)
 Object: Instances of classes
 NULL: Represents no value, e.g., null

34. What is an associative array in PHP?

An associative array in PHP is an array where each element is identified by a key rather than an
index. The keys can be strings or numbers.

Example:

php
$person = array("name" => "John", "age" => 25, "city" => "New York");
echo $person["name"]; // Outputs: John

35. What is the difference between include and require in PHP?


 include: Includes and evaluates the specified file. If the file is not found, it generates a
warning but the script continues to execute.
 require: Also includes and evaluates the specified file, but if the file is not found, it
generates a fatal error and stops the script execution.

36. What are the advantages of using PHP over other programming languages for web
development?

 Open Source: PHP is free and open-source.


 Cross-platform: PHP runs on various platforms like Windows, Linux, macOS.
 Database Support: It integrates well with databases like MySQL, PostgreSQL, etc.
 Huge Community: PHP has a large community, providing a lot of resources and
support.
 Ease of Learning: PHP is relatively easy to learn and use, especially for web
development.

37. How does PHP handle errors?

PHP has different levels of error handling:

 Notices: Minor errors like undefined variables.


 Warnings: Non-fatal errors, such as including a non-existent file.
 Fatal Errors: Serious issues, like calling a non-existent function or accessing an
undefined class.

PHP allows custom error handling using the set_error_handler() function to handle specific
errors.

38. How can you include PHP code in an HTML file?

PHP code can be included in an HTML file by embedding it within PHP tags <?php ?>.
The server processes the PHP code and returns the output as HTML.

Example:

php
<html>
<body>
<h1><?php echo "Welcome to PHP!"; ?></h1>
</body>
</html>
39. What do you mean by JSON

JSON stands for JavaScript Object Notation. It is a lightweight data-interchange format that is
easy for humans to read and write, and easy for machines to parse and generate. It is commonly
used for transmitting data between a server and a web application, or between systems.

JSON is based on two structures:

1. An ordered collection of values (often called an array or list in other languages)


represented by square brackets []. For example:

json
["apple", "banana", "cherry"]

2. A collection of key/value pairs (also called objects in JSON, similar to dictionaries or


maps in other languages) represented by curly braces {}. Each key is a string, and the
value can be any JSON data type (string, number, boolean, array, another object, or
null). For example:

json
{
"name": "John",
"age": 30,
"city": "New York"
}

JSON Data Types

 String: Text wrapped in double quotes ("example").


 Number: Numeric values (e.g., 25, 3.14).
 Boolean: true or false.
 Array: A list of values enclosed in square brackets ( []).
 Object: A set of key-value pairs enclosed in curly braces ({}).
 Null: A null value (null).

Example of a JSON object:


json
{
"firstName": "John",
"lastName": "Doe",
"age": 25,
"address": {
"street": "123 Main St",
"city": "Anytown",
"state": "CA"
},
"phoneNumbers": ["123-456-7890", "987-654-3210"]
}

JSON is widely used in APIs and web services to exchange data because of its simplicity and
ease of integration with various programming languages.

You might also like