0% found this document useful (0 votes)
5 views

computer_science_important_topics

Uploaded by

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

computer_science_important_topics

Uploaded by

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

1.

C++ Structures and Memory Management

Question: Define a structure in C++ and identify errors in structure definition.


Answer:
A structure in C++ is a user-defined data type that allows grouping different data
types together. Here's an example of defining a structure in C++:

struct Student {
int rollNo;
char name[50];
float marks;
};

Errors in structure definition:


- Incorrect use of semicolons.
- Declaring non-existing data types or incorrect data types.

Dynamic Memory Allocation in C++:


Dynamic memory is allocated at runtime using operators `new` and `delete`. Example:

int* p = new int; // Allocates memory dynamically


*p = 10; // Assigning value to dynamically allocated memory
delete p; // Deallocates memory

2. Polymorphism in C++ (OOP)

Question: What is polymorphism? Explain the different types of polymorphism with


examples.
Answer:
Polymorphism allows objects to be treated as instances of their parent class,
enabling methods to behave differently based on the object type.

Types of Polymorphism:
1. Compile-Time Polymorphism (Method Overloading):
- Multiple functions with the same name but different parameter lists.

Example:
class Calculator {
public:
int add(int a, int b) { return a + b; }
float add(float a, float b) { return a + b; }
};

2. Run-Time Polymorphism (Method Overriding):


- Derived class overrides a function in the base class. It occurs during
runtime.

Example:
class Animal {
public:
virtual void sound() { cout << "Some sound"; }
};

class Dog : public Animal {


public:
void sound() override { cout << "Bark"; }
};
Animal* a = new Dog();
a->sound(); // Output: Bark

3. Linked Lists

Question: Explain the structure of a linked list.


Answer:
A linked list is a linear data structure where each element (node) contains two
parts:
- Data: Stores the data.
- Next: Pointer to the next node in the list.

Example:

struct Node {
int data;
Node* next;
};

Node* head = nullptr;

Basic operations on linked lists include insertion, deletion, and traversal.

4. HTML Basics

Question: Write HTML code to create a table.


Answer:
To create a simple table in HTML:

<table border="1">
<tr>
<th>Roll No</th>
<th>Name</th>
<th>Marks</th>
</tr>
<tr>
<td>1</td>
<td>John</td>
<td>85</td>
</tr>
<tr>
<td>2</td>
<td>Jane</td>
<td>90</td>
</tr>
</table>

Question: Differentiate between internal and external linking in HTML.


Answer:
- Internal Linking: Links to other parts of the same webpage using anchors (<a>
tags) and id attributes.
Example:
<a href="#section2">Go to Section 2</a>
<div id="section2">This is Section 2</div>
- External Linking: Links to other webpages using a full URL.
Example:
<a href="https://www.example.com">Visit Example</a>

5. JavaScript Functions

Question: Explain built-in JavaScript functions like isNaN(), charAt(), and


alert().
Answer:
- isNaN(): Checks if a value is "Not-a-Number" (NaN).
Example:
isNaN(123); // false
isNaN('abc'); // true

- charAt(): Returns the character at a specified position in a string.


Example:
let str = "Hello";
console.log(str.charAt(1)); // 'e'

- alert(): Displays an alert box with a specified message.


Example:
alert("Hello, World!");

6. SQL Commands

Question: Write SQL statements to create, modify, and delete tables.


Answer:
- Create Table:
CREATE TABLE Student (
RollNo INT PRIMARY KEY,
Name VARCHAR(50),
Marks FLOAT
);

- Alter Table (to add a new column):


ALTER TABLE Student ADD Age INT;

- Delete Table:
DROP TABLE Student;

Question: How do you query data in SQL?


To select specific rows:
SELECT * FROM Student WHERE Marks > 50;

7. Primary Key and Foreign Key

Question: Differentiate between Primary Key and Foreign Key.


Answer:
- Primary Key: Uniquely identifies each record in a table. Each value in a primary
key must be unique.
Example: RollNo in a Student table.

- Foreign Key: A field that creates a relationship between two tables. It refers to
the primary key in another table.
Example: In an Order table, CustomerID could be a foreign key referring to
CustomerID in a Customer table.

8. Queue and Stack Operations

Question: Write an algorithm for the insertion operation in a QUEUE data structure.
Answer:
The Queue follows FIFO (First In First Out) order. For insertion (enqueue), you add
an element to the rear of the queue.

void enqueue(int arr[], int& rear, int element) {


if(rear < SIZE - 1) {
rear++;
arr[rear] = element;
} else {
cout << "Queue is full";
}
}

9. Responsive Web Design

Question: What is responsive web design?


Answer:
Responsive web design ensures that a website adjusts its layout and content based
on the screen size (e.g., desktop, tablet, mobile).

Example CSS:
@media (max-width: 600px) {
body {
background-color: lightblue;
}
}

10. Content Management Systems (CMS)

Question: What are the advantages of using CMS?


Answer:
- Ease of Use: Non-technical users can manage content.
- Customization: Offers themes, plugins, and flexibility.
- SEO Features: Built-in SEO tools for better website ranking.
- Security: Regular updates and security features to protect data.

11. FTP (File Transfer Protocol)

Question: Describe FTP client software.


Answer:
An FTP client allows you to transfer files between a local system and a remote
server. Examples include FileZilla and WinSCP.

12. Control Structures in JavaScript/PHP

Question: Explain control structures in JavaScript.


Answer:
JavaScript provides if-else, for, while, and switch statements for control flow.
Example (if-else):
let age = 18;
if (age >= 18) {
console.log("Adult");
} else {
console.log("Minor");
}

13. Web Hosting

Question: Differentiate between types of web hosting.


Answer:
- Shared Hosting: Multiple websites share the same server resources.
- Dedicated Hosting: Entire server resources are dedicated to one website.
- Cloud Hosting: Websites hosted on a cloud infrastructure for scalability.

You might also like