WT - Oral Questions

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

D .

Y Patil Pratishtan’s College of Engineering, Salokhenagar,


Kolhapur 416007
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Subject: Web

Technologies Class: B.Tech A & B

Oral Questions with Answers

UNIT-1 (Front End Web Designing (HTML and CSS)


1. What is the purpose of the DOCTYPE declaration in HTML?
It defines the document type and version of HTML being used to ensure
proper rendering by browsers.
2. Differentiate between block and inline elements in HTML with examples.
Block elements (<div>, <p>) take up the full width, while inline elements
(<span>, <a>) take up only the necessary width.
3. How do you define an ID selector in CSS?
An ID selector is defined using #idname {} in CSS to style an element with a
specific id attribute.
4. Explain the use of conditional stylesheets in HTML and CSS.
Conditional stylesheets apply specific CSS rules for different browsers,
commonly used for Internet Explorer compatibility.
5. What is the function of the <head> element in HTML?
It contains meta-information about the document, such as links to stylesheets,
scripts, and the document title.
6. Describe the role of structural block elements in organizing an HTML
document.
Structural block elements like <header>, <footer>, and <section> provide
semantic structure and define different sections of the page.
7. What is XHTML, and how does it differ from HTML?
XHTML is a stricter version of HTML that follows XML syntax rules, such
as closing all tags and using lowercase element names.
8. Explain the concept of CSS inheritance with an example.
CSS inheritance means that child elements inherit styles from their parent
elements, like font size from <body> to <p>.
9. What are pseudo-classes in CSS?
Pseudo-classes like :hover and :visited allow you to style elements based on
their state or user interaction.
10. How do you use Bootstrap to create responsive web designs?
Bootstrap provides a grid system and responsive utility classes (col-sm, col-md, etc.)
that automatically adjust layout for different screen sizes.
11. What are the three ways to include CSS in an HTML document?
Inline CSS, Internal CSS (within <style> tags in the HTML <head>), and External
CSS (using a separate .css file linked with <link>).
12. Explain the difference between inline, internal, and external CSS.
Inline CSS is written directly in the style attribute of an element, internal CSS is
within the <style> tag in the HTML document, and external CSS is linked through a
separate file using <link rel="stylesheet" href="style.css">.

UNIT-2 (Javascript Basics)


1. What is a variable in JavaScript?
•A variable in JavaScript is a container for storing data values, declared using var,
let, or const.
2. Write a basic JavaScript function to validate a form field (e.g., email validation).
• Example:

function validate Email() {


var email = document.getElementById("email").value;
var regex = /\S+@\S+\.\S+/;
return regex.test(email);
}

3. What is an array in JavaScript?


• An array is a collection of elements that can be stored in a single variable, e.g.,
var arr = [1, 2, 3].

4. Explain how JavaScript handles exceptions using try...catch with an example.


• JavaScript uses try to define a block of code to test, and catch to handle any
errors that occur. Example:
try {
// code that may throw an error
} catch (error) {
console.log(error);
}
5. What does DOM stand for in JavaScript?
• DOM stands for Document Object Model, which represents the structure of an
HTML document and allows JavaScript to manipulate it.

6. How can you manipulate HTML content using jQuery? Provide a simple example.
• You can use jQuery's .html() or .text() methods to change content. Example:
$("#element").html("New content");
7. What is the purpose of AJAX in JavaScript?
• AJAX allows you to send and receive data asynchronously without refreshing
the page.
8. How can you validate an HTML form using JavaScript? Write a simple code.
• Example:

function validateForm() {
var name = document.forms["myForm"]["name"].value;
if (name == "") {
alert("Name must be filled out");
return false;
}
}
9. What is the use of the event object in JavaScript?
• The event object contains information about the event that triggered an action,
such as the type of event or the element that was clicked.
10. Write a program demonstrating JavaScript loops and explain the
output. • Example:
for (var i = 0; i < 3; i++) {
console.log(i);
}
• Output: 0, 1, 2 (the loop runs 3 times, printing the values of i as it increments).

UNIT-3 (Angular Node JS)


1. What does MVC stand for in Angular?
• MVC stands for Model-View-Controller, a design pattern that separates an
application into three interconnected components: Model (data), View (UI), and
Controller (business logic).
2. Explain the Angular architecture and its main components.
• Angular architecture is component-based, consisting of Modules (organizing the
app), Components (UI building blocks), Templates (HTML views), Services
(shared logic), Dependency Injection (service management), and Routing
(navigation between views).
3. What is a directive in Angular?
A directive in Angular is a marker on a DOM element that attaches behavior or
manipulates the DOM, including types like Components, Structural Directives
(*ngIf, *ngFor), and Attribute Directives (ngStyle).
4. Write a simple Node.js program that demonstrates the use of event listeners.
const EventEmitter = require('events');
const myEmitter = new EventEmitter();
myEmitter.on('event', () => console.log('An event occurred!'));
myEmitter.emit('event');
5. What is the purpose of the event loop in Node.js?
• The event loop in Node.js enables non-blocking I/O operations by executing
callbacks for asynchronous events, allowing the application to handle multiple
operations concurrently.
6. How does Angular handle routing and navigation? Explain with an example.
• Angular uses the Router module for navigation. For example, routes can be
defined in app-routing.module.ts, and navigation is implemented using
<a routerLink="/">Home</a> and <router-outlet> in the template.
7. What is a callback function in Node.js?
•A callback function in Node.js is a function passed as an argument to another
function, which is executed after the completion of that function, often used in
asynchronous programming.
8. How do you consume REST web services in Angular? Explain with a use case.
• Angular consumes REST web services using the HttpClient module. For example,
in a service, you can fetch data from an API using this.http.get('api/url') to
retrieve user data for display.
9. What is MongoDB?
• MongoDB is a NoSQL database that stores data in flexible, JSON-like
documents, allowing for dynamic schema and scalability.
10. Explain how Node.js handles asynchronous events with an example.
• Node.js handles asynchronous events using callbacks, promises, or async/await.
For example, with a callback:
fs.readFile('file.txt', (err, data) => {
if (err) throw err;
console.log(data);
});
This reads a file without blocking the main thread.

UNIT-4 (PHP Basic)


1. What does PHP stand for?
• PHP stands for "Hypertext Preprocessor," which is a server-side scripting
language designed for web development.
2. Write a basic PHP program to output "Hello, World!" in the browser.
<?php
echo "Hello, World!";
?>
3. What is an array in PHP?
An array in PHP is a data structure that stores multiple values in a single variable,
allowing the storage of related data under one name.
4. Explain the difference between associative and indexed arrays in PHP.
Indexed arrays use numeric keys to access values (e.g., $array[0]), while
associative arrays use named keys (strings) for accessing values (e.g.,
$array['key']), allowing for more meaningful data association.
5. What is string interpolation in PHP?
String interpolation in PHP is the process of embedding variables within double
quoted strings, allowing the variable values to be evaluated and included in the
string (e.g., "Hello, $name").
6. Write a PHP code to merge and slice an array.
$array1 = [1, 2, 3];
$array2 = [4, 5, 6];
$mergedArray = array_merge($array1, $array2); // Merging arrays
$slicedArray = array_slice($mergedArray, 2, 3); // Slicing from index 2, length
3 7. How do you comment in PHP?
In PHP, comments can be made using // for single-line comments and /* ... */ for
multi-line comments.
8. Describe the control structures in PHP with an example of an if statement.
Control structures in PHP manage the flow of the program. For example, an if
statement checks a condition:
if ($x > 10) {
echo "x is greater than 10.";
}
9. What is a constant in PHP?
A constant in PHP is a variable whose value cannot be changed during script execution,
defined using the define() function (e.g., define("PI", 3.14);).

10. How do you define and call a function in PHP? Provide an


example. function greet($name) {
return "Hello, $name!";
}
echo greet("Alice"); // Calling the function
This code defines a function greet that returns a greeting message and calls it with the
argument "Alice".

UNIT-5 (PHP Session Management)


1. What is a session in PHP?
•A session is a way to store information (variables) to be used across multiple
pages for a single user.
2. Explain how sessions are started and destroyed in PHP with code examples.
• Starta session using session_start(), and destroy it using session_destroy().
Example:
session_start(); // to start a session
session_destroy(); // to destroy a session
3. What is a cookie in PHP?
•A cookie is a small piece of data stored on the client-side by the browser, used to
track user sessions or preferences.
4. Write a PHP program to create and retrieve a cookie.
Example:
setcookie("user", "John", time() + (86400 * 30)); // Set cookie for 30
days echo $_COOKIE["user"]; // Retrieve cookie value
5. How do you set a session variable in PHP?
Use $_SESSION superglobal to set session variables.
Example: $_SESSION['username'] = "JohnDoe";
6. What are the differences between session variables and cookies in PHP?
• Session
variables are stored on the server and expire when the session ends,
while cookies are stored on the client-side and have a set expiration time.
7. What is the default lifetime of a session in PHP?
• By default, a session lasts until the browser is closed or after 24 minutes of
inactivity.
8. Write a program to handle file uploads in PHP with validation for file type.
Example:
if ($_FILES['file']['type'] == 'image/jpeg') {
move_uploaded_file($_FILES['file']['tmp_name'], "uploads/" .
$_FILES['file']['name']);
}
9. How can you delete a session in PHP?
• Use session_destroy() to delete a session and unset($_SESSION['var']) to
remove session variables.
10. Write a PHP program to manage a user login session across multiple
pages. Example:
session_start();
if ($_SESSION['loggedin'] == true) {
echo "Welcome, " . $_SESSION['username'];
} else {
echo "Please log in.";
}
These concise answers provide a strong understanding of PHP session
management. Let me know if you need further details!
UNIT-6 (PHP Database and Laravel)
1. What is the MySQLi extension in PHP?
• The MySQLi extension is used to interact with MySQL databases in PHP,
providing improved functionality over the older MySQL extension.
2. How do you connect to a MySQL database using PHP? Provide an example.
Example:
$conn = new mysqli("localhost", "username", "password",
"database"); if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
3. Explain how to perform a simple SELECT query in PHP using MySQLi.
Use the query() method to run a SQL SELECT statement and fetch results.
Example:
$result = $conn->query("SELECT * FROM users");
while ($row = $result->fetch_assoc()) {
echo $row['username'];
}
4. How do you insert data into a MySQL database using PHP?
Example:
$sql = "INSERT INTO users (username, email) VALUES ('John',
'[email protected]')";
$conn->query($sql);
5. What is the purpose of transactions in a database?
• Transactions ensure that a series of SQL operations either completely succeed or
fail, maintaining data integrity.
6. Write a PHP code to execute a database transaction.
Example:
$conn->begin_transaction();
try {
$conn->query("INSERT INTO users (username) VALUES ('John')");
$conn->commit();
} catch (Exception $e) {
$conn->rollback();
}
7. What are the prerequisites for installing Laravel?
• Laravelrequires a web server (e.g., Apache), PHP version 7.2.5 or higher, and a
database (e.g., MySQL).
8. How do you create a simple route in Laravel?
Example:
Route::get('/hello', function () {
return "Hello, World!";
});
9. What is the purpose of migrations in Laravel?
• Migrationsare used to manage and version control the database schema,
allowing developers to modify and share database structure.
10. Write a simple Laravel code to interact with a database using Eloquent
ORM. Example:
$user = new User;
$user->name = 'John';
$user->email = '[email protected]';
$user->save();
• Theseanswers cover the key aspects of PHP database interactions and Laravel
basics. Let me know if you need more clarification!

You might also like