JavaScript in HTML Documents
Here are the answers to the 15 revised questions:
1. What is the purpose of JavaScript in HTML?
JavaScript is used to add interactivity and dynamic behavior to web pages, such as
form validation, animations, and event handling.
2. How does JavaScript add interactivity to a web page?
JavaScript executes code based on user interactions like clicking a button, submitting
a form, or loading a page. It can modify HTML content, apply styles dynamically, and
handle user inputs.
3. What is the document.write() method used for?
The document.write() method is used to display text or HTML content directly onto a
web page.
javascript
document.write("Hello, World!");
4. How can HTML tags be used inside JavaScript?
HTML tags can be included inside document.write() to dynamically create HTML
elements.
javascript
document.write("<h1>Welcome to JavaScript</h1>");
5. What are JavaScript variables, and how are they declared?
JavaScript variables store data values and can be declared using var, let, or const.
javascript
var name = "John";
let age = 25;
const pi = 3.14;
6. What are the rules for naming variables in JavaScript?
- Variable names are case-sensitive.
- They must begin with a letter, underscore _, or $.
- They cannot contain spaces.
- Reserved keywords cannot be used as variable names.
7. Name three types of JavaScript operators.
- Arithmetic Operators (e.g., +, -, *, /)
- Comparison Operators (e.g., ==, !=, <, >)
- Logical Operators (e.g., &&, ||, !)
8. What is the purpose of the window.alert() method?
The window.alert() method displays a popup alert box with a message.
javascript
alert("This is an alert box!");
9. How does the window.confirm() method work?
The window.confirm() method displays a confirmation box with "OK" and "Cancel"
buttons. It returns true if OK is pressed and false if Cancel is pressed.
javascript
var response = confirm("Do you agree?");
document.write(response);
10. What is the di erence between parseInt() and parseFloat()?
- parseInt() converts a string to an integer (whole number).
- parseFloat() converts a string to a floating-point (decimal) number.
javascript
var x = parseInt("42.5"); // Returns 42
var y = parseFloat("42.5"); // Returns 42.5
11. How can you display a prompt box in JavaScript?
The window.prompt() method is used to get user input through a dialog box.
javascript
var name = prompt("Enter your name:");
document.write("Hello, " + name);
12. What are arithmetic operators in JavaScript? Give two examples.
Arithmetic operators perform mathematical calculations.
javascript
var sum = 5 + 3; // Addition (+)
var product = 5 * 3; // Multiplication (*)
13. What is string concatenation in JavaScript?
String concatenation is the process of joining two or more strings using the + operator.
javascript
var greeting = "Hello" + " World!";
document.write(greeting);
14. What are comparison operators in JavaScript? Give an example.
Comparison operators compare values and return true or false.
javascript
var result = (10 > 5); // Returns true
document.write(result);
15. How does JavaScript handle comments in code?
- Single-line comments start with //.
- Multi-line comments are enclosed between /* ... */.
javascript
// This is a single-line comment
/* This is
a multi-line comment */
Introduction to Artificial Intelligence:
1. What is Artificial Intelligence (AI)?
Artificial Intelligence (AI) is the science and engineering of creating intelligent
machines that can think, learn, and perform tasks that typically require human
intelligence, such as problem-solving and decision-making.
2. Who is known as the father of Artificial Intelligence?
John McCarthy is known as the father of Artificial Intelligence. He defined AI as
"the science and engineering of making intelligent machines, especially
intelligent computer programs."
3. What are the main goals of AI?
o To develop systems that can think and behave like humans.
o To create expert systems that can analyze and provide solutions.
o To enable machines to understand and process natural language.
o To allow machines to perform cognitive tasks like reasoning and decision-
making.
4. Name any three application areas of AI.
o Intelligent Robots – AI-powered robots can perform human-like tasks and
learn from their experiences.
o Speech Recognition – AI can process and understand spoken language.
o Gaming – AI is used in games like chess to predict moves and improve
gameplay.
5. What are the di erent domains of AI?
o Mundane Tasks – Routine human tasks like common sense reasoning and
planning.
o Formal Tasks – Tasks requiring logical reasoning, such as playing chess.
o Expert Tasks – Complex tasks requiring specialized knowledge, like
medical diagnosis.
6. How do expert systems help in AI?
Expert systems are AI programs that provide advice or solutions in specialized
fields such as medicine and engineering. They mimic human decision-making by
analyzing large amounts of data.
7. What is the role of machine learning in AI?
Machine learning enables AI systems to learn from data, recognize patterns, and
improve performance over time without being explicitly programmed.
8. What are the five steps in AI problem-solving?
o Defining the problem – Clearly identifying the issue.
o Analyzing the problem – Understanding its requirements.
o Identifying solutions – Listing possible solutions.
o Choosing the best solution – Selecting the most e ective approach.
o Implementing the solution – Applying the chosen solution to solve the
problem.
9. What is an artificial neural network?
An artificial neural network (ANN) is a computing system inspired by the human
brain. It consists of layers of interconnected nodes (neurons) that process data
and recognize patterns to make predictions or decisions.
10. Mention two limitations of AI.
High Cost – Developing AI systems is expensive.
Lack of Emotions – AI lacks human-like emotions, creativity, and intuition.
Virus and Anti-virus
1. What is a computer virus?
A computer virus is a malicious software program designed to replicate itself and
spread from one computer to another, often causing damage by corrupting or
deleting files.
2. How does a computer virus spread?
A computer virus can spread through infected email attachments, removable
storage devices, downloading files from untrusted sources, and network
connections.
3. Name three symptoms of a computer virus infection.
o The computer runs slower than usual.
o Unexpected error messages or programs crashing frequently.
o Strange sounds or music playing from the computer unexpectedly.
4. What is a boot sector virus?
A boot sector virus infects the boot sector of a storage device, such as a hard
drive or USB. It activates when the computer starts, making it di icult to remove.
Examples include Michelangelo and Stoned viruses.
5. What is the di erence between a virus and a worm?
o A virus requires a host file to spread and infects files or programs.
o A worm spreads independently through networks and does not need a
host file.
6. What is a Trojan horse in computer security?
A Trojan horse is a malicious program that disguises itself as a legitimate file or
software but contains harmful code that can damage data or steal information.
Unlike viruses, Trojans do not replicate themselves.
7. What is the purpose of antivirus software?
Antivirus software is designed to detect, prevent, and remove viruses, worms,
and other malicious programs from a computer system.
8. Name two examples of antivirus software.
o Norton Antivirus
o McAfee Virus Scan
9. How can you protect your computer from viruses?
o Install and regularly update antivirus software.
o Avoid opening email attachments from unknown senders.
o Download software only from trusted sources.
o Enable a firewall for additional security.
10. What is spyware, and how does it a ect a computer?
Spyware is a type of malicious software that secretly collects information about
a user’s activities without their knowledge. It can slow down the system and
steal personal data, such as passwords and credit card information.
MS Access 2010
1. What is a database?
A database is an organized collection of data that allows easy storage, retrieval,
and management of information.
2. What is the purpose of Microsoft Access?
Microsoft Access is a database management system (DBMS) that allows users to
create, manage, and manipulate databases using tables, queries, forms, and
reports.
3. What is a table in MS Access?
A table is a collection of data stored in rows and columns within a database.
Each row represents a record, and each column represents a field.
4. Define a record in a database table.
A record is a single row in a database table that contains related information
about an entity, such as a student’s name, admission number, and contact
details.
5. What is a field in a database?
A field is a column in a table that stores a specific type of data, such as a
student's name, date of birth, or phone number.
6. What is the function of a Database Management System (DBMS)?
A DBMS helps in creating, storing, managing, and retrieving data e iciently. It
ensures data security, reduces redundancy, and maintains consistency.
7. Name two types of database objects in MS Access.
o Tables – Store data in structured formats.
o Queries – Retrieve and manipulate data based on specific conditions.
8. What is a primary key in a database table?
A primary key is a unique identifier for each record in a table. It ensures that no
two records have the same value in the key field.
9. What is the purpose of queries in MS Access?
Queries are used to retrieve, filter, sort, and manipulate data stored in tables
based on specific conditions.
10. How do forms help in managing data in MS Access?
Forms provide a user-friendly interface for entering, editing, and viewing data in a
structured format.
11. What is the use of reports in MS Access?
Reports help in presenting data in a printable and structured format, making it
easier to analyze and share information.
12. Name two common data types used in MS Access.
Text – Stores alphanumeric characters (e.g., names, addresses).
Number – Stores numeric values for calculations.
13. What is the file extension of an MS Access 2010 database?
The file extension for an MS Access 2010 database is .accdb.
14. How can you create a new database in MS Access?
Open MS Access.
Click on "Blank Database."
Enter a database name.
Click "Create."
15. What are the steps to save a database in MS Access?
Click on the File menu.
Select Save Database As.
Choose a location, enter a file name, and click Save.
16. What is a field property in MS Access?
A field property defines the characteristics and behavior of data stored in a field,
such as size, format, and default value.
17. What is the function of the Field Size property?
The Field Size property determines the maximum number of characters or digits
allowed in a field.
18. How does the Format property help in displaying data?
The Format property controls how data appears in the table, such as date
formatting (e.g., "MM/DD/YYYY") or currency formatting.
19. What is the purpose of the Caption property?
The Caption property allows a user-friendly name to be displayed instead of the
field name. For example, a field named DOB can have a caption Date of Birth.
20. How does the Indexed property a ect a table’s performance?
The Indexed property speeds up searching and sorting in a table but may slow
down data entry and updates.