PART 1 – JavaScript
Q1. What is JavaScript?
Answer:
JavaScript is a scripting language used to make web pages interactive and dynamic.
Q2. What are variables?
Answer:
Variables are containers used to store data.
Example:
let age = 20;
Q3. Difference between let and const?
let
Value can change.
const
Value cannot be changed after declaration.
Q4. What is [Link]()?
Answer:
It displays output in the browser console.
Example:
[Link]("Hello");
Q5. What are JavaScript data types?
Answer
Number
String
Boolean
Null
Undefined
Object
Q6. What is String Concatenation?
Answer
Combining two or more strings using the + operator.
Example:
"Hello " + "World"
Output:
Hello World
Q7. What are arithmetic operators?
Answer
+
/
%
++
**
Q8. What is an Alert Box?
Answer
An alert box displays a popup message.
Example:
alert("Welcome");
Q9. How do you link an external JavaScript file?
Answer
<script src="[Link]"></script>
PART 2 – Conditional Statements
Q10. What is an if statement?
Answer
Executes code only when a condition is true.
Example:
if(age>18){[Link]("Adult");
}
Q11. What is if...else?
Answer
Executes one block if condition is true, otherwise executes another block.
Q12. What is else if?
Answer
Checks multiple conditions one after another.
Q13. What are relational operators?
Answer
==
!=
<
<=
They compare two values and return true or false.
Q14. What are nested if statements?
Answer
An if statement placed inside another if statement.
Q15. Difference between multiple if statements and if-else?
Answer
Multiple if → More than one condition may execute.
if-else → Only one block executes.
PART 3 – Flow Control
Q16. What is Flow Control?
Answer
Flow control decides which statements execute depending on conditions.
Q17. What is a Compound Statement?
Answer
A group of multiple statements enclosed inside { }.
Q18. What is a switch statement?
Answer
It selects one option from many possible values.
Example:
switch(day){case "Monday":break;default:
}
Q19. When should switch be used?
Answer
When checking one variable against many possible values.
Q20. Difference between if-else and switch?
if-else
Multiple conditions
More flexible
switch
One variable
Faster and cleaner for many cases
PART 4 – Loops
Q21. What is a loop?
Answer
A loop repeats a block of code until a condition becomes false.
Q22. What is a for loop?
Answer
Used when the number of repetitions is known.
Syntax:
for(initialization;condition;increment)
Q23. What is a while loop?
Answer
Repeats code while the condition is true.
Q24. Difference between for and while?
For Loop
Number of iterations known.
While Loop
Number of iterations unknown.
Q25. What are the three parts of a for loop?
Answer
1. Initialization
2. Condition
3. Increment/Decrement
PART 5 – Web Hosting
Q26. What is Web Hosting?
Answer
A service that stores websites on servers so they can be accessed through the Internet.
Q27. What is a Web Server?
Answer
A computer or software that stores and delivers web pages.
Q28. What is DNS?
Answer
DNS (Domain Name System) converts domain names into IP addresses.
Q29. What is a Domain Name?
Answer
A human-readable website name.
Example:
[Link]
Q30. What is URL?
Answer
A URL is the complete web address of a webpage.
Example:
[Link]
Q31. What is FTP?
Answer
FTP (File Transfer Protocol) transfers files between a computer and a server.
Q32. What is ISP?
Answer
Internet Service Provider provides Internet access.
Example:
PTCL, Nayatel, StormFiber.
PART 6 – Types of Hosting
Q33. What is Free Hosting?
Answer
Free hosting with limited features and advertisements.
Q34. What is Shared Hosting?
Answer
Many websites share one server.
Q35. What is VPS Hosting?
Answer
One physical server divided into several virtual servers.
Q36. What is Dedicated Hosting?
Answer
One customer gets an entire server.
Q37. What is Colocation Hosting?
Answer
Customer owns the server while the hosting company provides space and Internet.
PART 7 – Domain Names
Q38. What is a Top-Level Domain (TLD)?
Answer
The last part of a domain.
Examples:
.com
.org
.net
Q39. What is a Subdomain?
Answer
A subdivision of a domain.
Example:
[Link]
Q40. What are Generic TLDs?
Answer
Examples:
.com
.org
.net
.info
Q41. What are Country Code TLDs?
Answer
Examples:
.pk
.uk
.us
PART 8 – Databases & Programming
Q42. What is MySQL?
Answer
An open-source database used to store website data.
Q43. What is PHP?
Answer
A server-side scripting language used to build dynamic websites.
Q44. What is phpMyAdmin?
Answer
A web application used to manage MySQL databases.
Q45. What is XAMPP?
Answer
A local server package containing Apache, PHP and MySQL for website development.
Q46. What is Apache?
Answer
Apache is one of the most popular web server software.
Q47. What is cPanel?
Answer
A graphical control panel used to manage web hosting.
Q48. What is CMS?
Answer
CMS (Content Management System) helps create and manage websites without much
coding.
Examples:
WordPress
Joomla
Drupal
⭐ Most Important Viva/Exam
Questions (Must Prepare)
1. What is JavaScript?
2. Difference between let and const.
3. Explain if, if-else, and switch.
4. Difference between for and while loop.
5. What is Flow Control?
6. What is Web Hosting?
7. Types of Web Hosting.
8. What is DNS?
9. Difference between Domain Name and URL.
10. What is FTP?
11. What is a Web Server?
12. What is MySQL?
13. What is PHP?
14. What is XAMPP?
15. Difference between Shared Hosting and Dedicated Hosting.
Week 4 – Python Decision Making
Q1. What is decision making in Python?
Answer: Decision making allows a program to choose different actions based on a
condition using if, if-else, and elif.
Q2. What is an if statement?
Answer: An if statement executes a block of code only when its condition is True.
Q3. Syntax of if statement?
Answer:
if condition:
statements
Q4. What is indentation in Python?
Answer: Indentation defines the block of code belonging to statements like if, for,
and while.
Q5. What is if-else?
Answer: if-else executes one block if the condition is True and another block if it
is False.
Q6. Difference between if and if-else?
Answer:
if: Executes only when condition is True.
if-else: Executes one of two blocks depending on the condition.
Q7. What is a nested if?
Answer: A nested if is an if statement inside another if statement.
Q8. What is if-elif-else ladder?
Answer: It checks multiple conditions one by one and executes the first True block. If
none is True, else executes.
Q9. Why use elif?
Answer: To test multiple conditions without writing many separate if statements.
Q10. What is shorthand if?
Answer:
if x > 5: print(x)
Q11. What is shorthand if-else?
Answer:
print("Yes") if x>5 else print("No")
Q12. What are comparison operators?
Answer: Operators used to compare values:
==, !=, >, <, >=, <=
Q13. What are logical operators?
Answer:
and → both conditions True
or → at least one True
not → reverses result
Week 7 – Loops
Q14. What is len() function?
Answer: len() returns the number of items in a string, list, or other sequence.
Q15. Example of len().
Answer:
len("Python")
Output:
Q16. What is indexing?
Answer: Indexing is used to access elements using their position starting from 0.
Q17. What is a nested loop?
Answer: A loop inside another loop. Total iterations = Outer loop × Inner loop.
Q18. What is the use of nested loops?
Answer: To print patterns, multiplication tables, and work with rows and columns.
Q19. What is a while loop?
Answer: A while loop repeats statements as long as the condition is True.
Q20. Syntax of while loop?
Answer:
while condition:
statements
Q21. What is break statement?
Answer: break immediately terminates the loop.
Q22. What is continue statement?
Answer: continue skips the current iteration and moves to the next one.
Q23. What is while-else?
Answer: The else block executes when the loop ends normally (not by break).
Q24. Difference between break and continue?
Answer:
break: Stops the loop completely.
continue: Skips one iteration and continues.
JavaScript (Scripts & Conditionals)
Q25. What is string concatenation?
Answer: Joining strings using the + operator.
Q26. What is alert()?
Answer: alert() displays a popup message.
Q27. How do you link a JavaScript file?
Answer:
<script src="[Link]"></script>
Q28. What is an if statement in JavaScript?
Answer: Executes code only if a condition is True.
Q29. What is if-else in JavaScript?
Answer: Executes one block if True and another if False.
Q30. What is else if?
Answer: Checks another condition if the previous one is False.
Q31. What are relational operators?
Answer:
==, !=, >, <, >=, <=
Q32. What is a Boolean value?
Answer: A value that is either True or False.
Q33. Difference between nested if and else if?
Answer:
Nested if: if inside another if.
else if: Checks multiple conditions sequentially.
Q34. Which structure is used for multiple conditions?
Answer: if → else if → else
⭐ Most Important Exam Questions
1. Define decision making.
2. Explain if statement.
3. Explain if-else.
4. Explain nested if.
5. Explain if-elif-else.
6. What is shorthand if?
7. Explain comparison operators.
8. Explain logical operators.
9. Define len().
10. What is indexing?
11. Define nested loop.
12. Define while loop.
13. Difference between break and continue.
14. Explain while-else.
15. What is string concatenation?
16. Explain JavaScript if-else.
17. What are relational operators?
18. Difference between nested if and else if.
LONG ANSWERS
1. What is Decision Making in
Python?
Answer:
Decision making is the process of executing different blocks of code depending on
whether a condition is True or False. It controls the flow of a program and allows the
program to make decisions based on user input or logical conditions. Python uses if,
if-else, and if-elif-else statements for decision making.
Example
age = 18if age >= 18:
print("Eligible to vote")
2. What is an if Statement?
Answer:
The if statement is the simplest decision-making statement in Python. It executes a
block of code only when the specified condition evaluates to True. If the condition is
False, the program skips that block and continues with the next statement.
Syntax
if condition:
statements
Example
marks = 75if marks >= 50:
print("Pass")
3. What is if-else Statement?
Answer:
The if-else statement is used when there are two possible outcomes. If the condition
is True, the if block executes; otherwise, the else block executes. This is known as
two-way decision making.
Syntax
if condition:
statementselse:
statements
Example
age = 16
if age >= 18:
print("Adult")else:
print("Minor")
4. What is Nested if Statement?
Answer:
A nested if statement is an if statement inside another if statement. It is used when
one condition must be checked only after another condition is True. Nested if
statements are useful when multiple related conditions need to be verified.
Example
age = 20citizen = True
if age >= 18:
if citizen:
print("Eligible to vote")
5. What is if-elif-else Ladder?
Answer
The if-elif-else ladder is used when there are multiple conditions to check. Python
checks each condition from top to bottom. As soon as one condition becomes True, its
block executes and the remaining conditions are skipped. If none of the conditions are
True, the else block executes.
Example
marks = 82
if marks >= 90:
print("A")elif marks >= 80:
print("B")elif marks >= 70:
print("C")else:
print("Fail")
6. What is Indentation in Python?
Answer
Indentation means leaving spaces before a line of code. Python uses indentation to
identify the block of code belonging to loops, functions, and conditional statements.
Incorrect indentation causes an error.
Example:
if True:
print("Hello")
7. What are Comparison Operators?
Answer
Comparison operators compare two values and return either True or False.
Operator Meaning
== Equal to
!= Not equal to
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to
Example:
10 > 5
Output:
True
8. What are Logical Operators?
Answer
Logical operators combine multiple conditions.
and
Returns True only if both conditions are True.
or
Returns True if at least one condition is True.
not
Reverses the Boolean value.
Example
age = 20citizen = True
print(age >=18 and citizen)
Output:
True
9. What is len() Function?
Answer
The len() function returns the total number of items in an object. For a string, it
returns the number of characters. For a list or tuple, it returns the number of elements.
Example
name = "Python"print(len(name))
Output
10. What is Indexing?
Answer
Indexing is used to access individual elements of a string or list using their position
number. Python starts indexing from 0.
Example
name = "Python"
print(name[0])
Output
P
11. What is a Nested Loop?
Answer
A nested loop is a loop inside another loop. The inner loop executes completely every
time the outer loop runs. It is commonly used for printing patterns, multiplication
tables, and working with matrices.
Example
for i in range(3):
for j in range(3):
print("*", end="")
print()
Output
***
***
***
12. What is While Loop?
Answer
A while loop repeatedly executes a block of code as long as the specified condition
remains True. The condition is checked before every iteration. When it becomes False,
the loop stops.
Syntax
while condition:
statements
Example
i = 1
while i <= 5:
print(i)
i += 1
13. What is Break Statement?
Answer
The break statement immediately terminates the loop regardless of the loop condition.
It is used when the required result has been achieved before completing all iterations.
Example
for i in range(10):
if i == 5:
break
print(i)
Output
0
1
2
3
4
14. What is Continue Statement?
Answer
The continue statement skips the current iteration and immediately moves to the next
iteration of the loop. The loop itself does not stop.
Example
for i in range(5):
if i == 2:
continue
print(i)
Output
0
1
3
4
15. What is While-Else Statement?
Answer
The else block of a while loop executes only when the loop finishes normally. If the
loop is terminated using a break statement, the else block does not execute.
Example
i = 1
while i <= 3:
print(i)
i += 1else:
print("Loop Finished")
16. What is String Concatenation
in JavaScript?
Answer
String concatenation means joining two or more strings using the + operator. It is used
to create longer strings or combine text with variables.
Example
let name = "Ali";[Link]("Hello " + name);
Output
Hello Ali
17. What is an if Statement in
JavaScript?
Answer
The JavaScript if statement executes a block of code only when the specified
condition is True. It is used for decision making in JavaScript programs.
Example
let age = 20;
if(age >= 18){
[Link]("Adult");
}
18. What are Relational Operators
in JavaScript?
Answer
Relational operators compare two values and return true or false.
== Equal to
!= Not Equal to
> Greater than
< Less than
>= Greater than or Equal to
<= Less than or Equal to
Example
10 > 5
Output
true
1. What is JavaScript?
Answer:
JavaScript is a high-level, interpreted scripting language used to make web pages
interactive and dynamic. It allows developers to add functionality such as animations,
form validation, calculations, pop-up messages, image sliders, and interactive menus.
JavaScript runs directly in the web browser and can also be executed outside the
browser using [Link].
Example:
[Link]("Hello World");
Key Points
Client-side scripting language
Makes websites interactive
Works with HTML and CSS
Can also run on servers using [Link]
2. What are Variables?
Answer:
A variable is a named memory location used to store data. The value stored in a
variable can be changed during program execution.
Example
let name = "Ali";let age = 20;
Here,
name stores a string.
age stores a number.
3. Difference Between let and
const
let const
Value can be changed Value cannot be changed
Used for variables Used for constants
Can be reassigned Cannot be reassigned
Example
let marks = 90;marks = 95;
const pi = 3.14;// pi = 4; Error
4. What is [Link]()?
Answer:
[Link]() is a JavaScript function used to display output in the browser's
developer console. It is mainly used for debugging and testing programs.
Example
[Link]("Welcome");[Link](25);
5. What are JavaScript Data Types?
Answer:
A data type specifies the kind of value stored in a variable.
Main Data Types
Number
Stores integers and decimal values.
let age = 20;
String
Stores text.
let city = "Lahore";
Boolean
Stores either true or false.
let passed = true;
Null
Represents an empty value.
let x = null;
Undefined
Variable declared but no value assigned.
let y;
Object
Stores multiple values.
let student = {
name:"Ali",
age:20
};
6. What is String Concatenation?
Answer:
String concatenation means joining two or more strings using the + operator.
Example
let first = "Muhammad";let last = "Ali";
[Link](first + " " + last);
Output
Muhammad Ali
7. Explain JavaScript Operators.
Answer
Operators perform operations on values.
Arithmetic Operators
Operator Meaning
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulus
++ Increment
-- Decrement
** Exponent
Example
let a=10;let b=5;
[Link](a+b);[Link](a-b);[Link](a*b);
8. What is an Alert Box?
Answer
An Alert Box displays a popup message to the user.
Syntax
alert("Hello");
Uses
Display messages
Warnings
Notifications
9. How do you link an External
JavaScript File?
Answer
External JavaScript files are linked using the <script> tag.
<script src="[Link]"></script>
Advantages
Easy maintenance
Reusable code
Faster loading
10. What is an if Statement?
Answer
The if statement executes a block of code only when the condition is true.
Syntax
if(condition){statements;
}
Example
let age=20;
if(age>=18){[Link]("Adult");
}
11. What is if...else?
Answer
The if...else statement executes one block if the condition is true and another block if
it is false.
Example
let age=15;
if(age>=18){[Link]("Adult");
}else{[Link]("Minor");
}
12. What is else if?
Answer
The else if statement checks multiple conditions one after another.
Example
let marks=80;
if(marks>=90)[Link]("A");
else if(marks>=80)[Link]("B");
[Link]("Fail");
13. What are Relational Operators?
Answer
Relational operators compare two values and return either true or false.
Operator Meaning
== Equal
!= Not Equal
> Greater Than
< Less Than
>= Greater Than or Equal
<= Less Than or Equal
14. What are Nested if Statements?
Answer
A Nested if is an if statement placed inside another if statement.
Example
if(age>=18){if(citizen==true){[Link]("Eligible");
}
}
Used when multiple conditions must be checked.
15. Difference Between if, if-else
and if-else-if
if
Checks one condition.
if-else
Chooses between two options.
if-else-if
Chooses among multiple options.
16. What is Flow Control?
Answer
Flow Control determines the order in which program statements execute. It allows a
program to make decisions and repeat tasks.
Flow control includes
if
if-else
switch
loops
17. What is a Compound Statement?
Answer
A Compound Statement is a group of multiple statements enclosed inside curly braces
{}.
Example
if(age>=18){
[Link]("Adult");[Link]("Eligible");
}
18. What is a switch Statement?
Answer
A switch statement selects one block of code from many possible options based on the
value of a variable.
Syntax
switch(day){
case "Monday":[Link]("Start");break;
default:[Link]("Invalid");
}
19. Difference Between switch and
if-else
if-else switch
Multiple conditions Single variable
More flexible Faster for many cases
Can use ranges Checks exact values
20. What is a Loop?
Answer
A loop repeatedly executes a block of code until a condition becomes false.
Advantages
Saves time
Reduces code repetition
Makes programs efficient
21. What is a for Loop?
Answer
A for loop is used when the number of repetitions is already known.
Syntax
for(initialization;condition;increment){
statements;
}
Example
for(let i=1;i<=5;i++){
[Link](i);
}
22. What is a while Loop?
Answer
A while loop executes repeatedly as long as the condition remains true.
Example
let i=1;
while(i<=5){
[Link](i);
i++;
}
23. Difference Between for and
while Loop
for while
Number of iterations known Number unknown
Initialization inside loop Initialization outside
Mostly counting loops Condition-based loops
24. What are the Three Parts of a
for Loop?
1. Initialization
2. Condition
3. Increment or Decrement
Example
for(let i=1;i<=10;i++)
let i=1 → Initialization
i<=10 → Condition
i++ → Increment
25. What is Web Hosting?
Answer
Web Hosting is a service that stores website files on a server connected to the Internet
so users can access the website at any time.
Examples:
Shared Hosting
VPS Hosting
Dedicated Hosting
26. What is a Web Server?
Answer
A Web Server is a computer or software that stores website files and sends them to
users through a web browser using HTTP.
Examples:
Apache
IIS
Nginx
27. What is DNS?
Answer
DNS (Domain Name System) converts a human-readable domain name into an IP
address.
Example:
[Link]
↓
[Link]
Without DNS, users would have to remember IP addresses instead of website names.
28. What is a Domain Name?
Answer
A Domain Name is the unique, human-readable name of a website.
Examples:
[Link]
[Link]
[Link]
29. What is URL?
Answer
URL (Uniform Resource Locator) is the complete web address used to locate a
webpage on the Internet.
Example:
[Link]
Components:
Protocol (https)
Domain name
Path
30. What is FTP?
Answer
FTP (File Transfer Protocol) is a protocol used to upload, download, and manage files
between a local computer and a web server.
Uses:
Upload website files
Download backups
Manage server files
31. What is ISP?
Answer
ISP (Internet Service Provider) is a company that provides Internet access to users.
Examples:
PTCL
Nayatel
StormFiber
32. Types of Web Hosting
1. Free Hosting
Free of cost
Limited storage and features
Suitable for learning
2. Shared Hosting
Multiple websites share one server
Low cost
Best for small websites
3. VPS (Virtual Private Server)
One server divided into virtual servers
Better performance than shared hosting
More control
4. Dedicated Hosting
One customer gets the entire server
High performance
Expensive
5. Colocation Hosting
Customer owns the server
Hosting company provides space, power, and Internet
Highest level of control
33. What is a Top-Level Domain
(TLD)?
Answer
A Top-Level Domain (TLD) is the last part of a domain name.
Examples:
.com
.net
.org
.edu
34. What is a Subdomain?
Answer
A Subdomain is a subdivision of a main domain used to organize different sections of
a website.
Example:
[Link]
[Link]
35. Difference Between Generic TLD
and Country Code TLD
Generic TLD Country Code TLD
.com .pk
.org .uk
.net .us
Used worldwide Represents a specific country
36. What is MySQL?
Answer
MySQL is an open-source Relational Database Management System (RDBMS) used
to store and manage website data such as user accounts, products, and orders.
37. What is PHP?
Answer
PHP (Hypertext Preprocessor) is a server-side scripting language used to create
dynamic websites and interact with databases like MySQL.
38. What is phpMyAdmin?
Answer
phpMyAdmin is a web-based application used to create, edit, delete, import, and
export MySQL databases through a graphical interface.
39. What is XAMPP?
Answer
XAMPP is a free local server package that includes:
Apache
MySQL
PHP
Perl
It allows developers to run websites on their own computers without an Internet
connection.
40. What is Apache?
Answer
Apache is one of the world's most widely used web server software. It receives
requests from browsers and delivers web pages to users.
41. What is cPanel?
Answer
cPanel is a graphical web hosting control panel used to manage websites, domains,
databases, email accounts, backups, and files without using command-line tools.
42. What is a CMS?
Answer
CMS (Content Management System) is software that allows users to create, edit, and
manage website content without writing extensive code.
Examples:
WordPress
Joomla
Drupal
Blogger
Advantages:
Easy website management
No advanced programming required
Supports themes and plugins
Faster website development