Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

FST Class 2023- Quiz 3

Total questions: 8

Worksheet time: 7mins

Name
Class
Date
1.

What is the purpose of the `else` clause in an `if-else` statement?

a)

   To define multiple conditions

b)

   To create a new block of code

c)

   To handle the case when the `if` condition is true

d)

   To handle the case when the `if` condition is false

2.

How do you write an `if-else` statement with multiple conditions?

a)

    if (condition1 && condition2)

b)

    if (condition1 || condition2)

c)

    if (condition1) else if (condition2)

d)

    if (condition1) else else (condition2)

3.

3. What is the output of the following code?

ar num = 10;

if (num > 8) {

console.log("Greater than 8");

} else if (num > 10) {

console.log("Greater than 10");

} else {

console.log("Other");

}

a)

 Greater than 5

b)

 Greater than 8

c)

Other

d)

   d) No output

4.

What does a nested `if-else` statement consist of?

a)

    Two separate `if` statements

b)

    An `if` statement inside an `else` statement

c)

   Multiple `if` statements combined using logical operators

d)

    An `if` statement inside another `if` statement

5.

Which of the following correctly shows the syntax for a nested `if-else` statement?

a)

    if (condition1) if (condition2)

b)

    if (condition1) { if (condition2) }

c)

   if (condition1) else (condition2)

d)

    if { condition1 } else { condition2 }

6.

What will be the output if the condition in an `if` statement is false and there is no `else` block?

a)

   It will throw an error

b)

    It will output "false"

c)

    It will output "true"

d)

   There will be no output

7.

What is the purpose of the `else if` clause in an `if-else` statement?

a)

     It is used to create a nested condition

b)

     It is used to handle multiple conditions sequentially

c)

     It is used to define the final else condition

d)

    d) It is used to create a new code block

8.

What is the purpose of the `else if` clause in an `if-else` statement?

a)

     It is used to create a nested condition

b)

     It is used to handle multiple conditions sequentially

c)

     It is used to define the final else condition

d)

    d) It is used to create a new code block