0% found this document useful (0 votes)
15 views5 pages

Reference

Uploaded by

venkat lokesh
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)
15 views5 pages

Reference

Uploaded by

venkat lokesh
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/ 5

Here are the **detailed answers** to all the questions from the image:

---

### 1. **HTML Tags Related to Table and Di erent Types of Lists with Sample Code**
- **HTML Table Tags**:
- `<table>`: De nes a table.
- `<tr>`: Table row.
- `<th>`: Table header.
- `<td>`: Table data.
- `<caption>`: Table caption.

**Sample Table:**
```html
<table border="1">
<caption>Student Grades</caption>
<tr>
<th>Name</th>
<th>Grade</th>
</tr>
<tr>
<td>John</td>
<td>A</td>
</tr>
<tr>
<td>Jane</td>
<td>B</td>
</tr>
</table>
```

- **Types of Lists**:
1. **Ordered List** (`<ol>`):
```html
<ol>
<li>First item</li>
<li>Second item</li>
</ol>
```
2. **Unordered List** (`<ul>`):
```html
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
```
3. **Description List** (`<dl>`):
```html
<dl>
<dt>HTML</dt>
<dd>Hypertext Markup Language</dd>
</dl>
```

---

### 2. **Various Types of CSS with Examples**


1. **Inline CSS**: Styles applied directly to an element.
```html
<p style="color: red;">This is inline CSS</p>
fi
ff
```
2. **Internal CSS**: De ned within a `<style>` block in the `<head>`.
```html
<style>
h1 { color: blue; }
</style>
```
3. **External CSS**: In a separate CSS le.
```html
<link rel="stylesheet" href="styles.css">
```

---

### 3. **Di erence Between CSS and CSS3**


- **CSS**:
- Basic styling like colors, fonts, and margins.
- **CSS3**:
- Adds new features like animations, transitions, shadows, and media queries.

---

### 4. **Di erent Data Types in JavaScript**


1. **Primitive Types**:
- `String`: `"Hello"`
- `Number`: `42`
- `Boolean`: `true` or `false`
- `Null`: A variable with no value (`null`)
- `Unde ned`: A variable declared but not assigned
- `BigInt`: Large integers
- `Symbol`: Unique values

2. **Non-Primitive Types**:
- Objects: `{name: "John"}`
- Arrays: `[1, 2, 3]`

---

### 5. **JavaScript Code to Handle `onsubmit` and `onload` Events**


```html
<body onload="alert('Page Loaded')">
<form onsubmit="return validateForm()">
<input type="text" name="username" />
<input type="submit" value="Submit" />
</form>

<script>
function validateForm() {
alert('Form Submitted');
return false; // Prevents form from actually submitting
}
</script>
</body>
```

---

### 6. **JavaScript to Find Largest and Smallest Values in an Array**


```javascript
let numbers = [10, 45, 2, 88, 34, 5];
fi
ff
ff
fi
fi
let max = Math.max(...numbers);
let min = Math.min(...numbers);

console.log("Max:", max); // Max: 88


console.log("Min:", min); // Min: 2
```

---

### 7. **Various Event Handlers in JavaScript with Examples**


- **`onclick`**:
```html
<button onclick="alert('Button clicked!')">Click Me</button>
```
- **`onmouseover`**:
```html
<div onmouseover="console.log('Mouse over!')">Hover over me</div>
```
- **`onkeydown`**:
```html
<input type="text" onkeydown="console.log('Key pressed!')" />
```

---

### 8. **JavaScript to Check if a Number is Prime**


```javascript
function isPrime(num) {
if (num <= 1) return false;
for (let i = 2; i <= Math.sqrt(num); i++) {
if (num % i === 0) return false;
}
return true;
}

console.log(isPrime(7)); // true
console.log(isPrime(10)); // false
```

---

### 9. **Two Ways of Form Validation in JavaScript**


1. **Client-Side Validation**:
Uses JavaScript to validate input before form submission.
```javascript
function validate() {
let name = document.getElementById("name").value;
if (name === "") {
alert("Name cannot be empty");
return false;
}
}
```

2. **Server-Side Validation**:
The data is validated after submission on the server (e.g., with PHP, Node.js).

---

### 10. **Operators in JavaScript**


- **Arithmetic Operators**: `+`, `-`, `*`, `/`, `%`.
- **Comparison Operators**: `==`, `===`, `!=`, `>`, `<`.
- **Logical Operators**: `&&`, `||`, `!`.
- **Assignment Operators**: `=`, `+=`, `-=`.

Example:
```javascript
let a = 10;
let b = 5;
console.log(a + b); // 15
console.log(a > b); // true
```

---

### 11. **Methods of Strings in JavaScript**


- **`length`**: Returns the length of the string.
- **`toUpperCase()`**: Converts to uppercase.
- **`slice()`**: Extracts part of the string.

Example:
```javascript
let str = "Hello, World!";
console.log(str.length); // 13
console.log(str.toUpperCase()); // "HELLO, WORLD!"
console.log(str.slice(0, 5)); // "Hello"
```

---

### 12. **try, catch, throw, and nally Keywords in Java Exception Handling**
- **`try`**: Block to test code for errors.
- **`catch`**: Handles errors.
- **`throw`**: Manually throws an exception.
- **` nally`**: Executes regardless of an error.

Example:
```java
try {
int result = 10 / 0;
} catch (ArithmeticException e) {
System.out.println("Error: Division by zero");
} nally {
System.out.println("This block runs regardless of an error");
}
```

---

### 13. **Features of Java**


- **Platform Independent**: Java runs on any device with a JVM.
- **Object-Oriented**: Java supports OOP concepts.
- **Robust**: Features like exception handling and garbage collection.
- **Multithreading**: Supports multiple threads running concurrently.
- **Security**: Provides a secure environment through byte code veri cation.

---

### 14. **OOP Features**


1. **Encapsulation**: Hides internal state and behavior by restricting access to methods.
fi
fi
fi
fi
2. **Inheritance**: A child class inherits properties from a parent class.
```java
class Animal {
void sound() { System.out.println("Animals make sound"); }
}
class Dog extends Animal {
void sound() { System.out.println("Dog barks"); }
}
```
3. **Polymorphism**: One method behaves di erently depending on the object.
```java
Animal a = new Dog();
a.sound(); // Dog barks
```
4. **Abstraction**: Hides complex implementation and exposes only essential features.

---

These are detailed answers to all the questions from the image. Let me know if you need further
clari cations!
fi
ff

You might also like