0% found this document useful (0 votes)
23 views6 pages

JavaScript MCQs on Control Structures

The document contains a series of multiple choice questions (MCQs) related to programming concepts, particularly focusing on control structures such as if statements, loops, and switch statements. Each question is accompanied by four answer options, with the correct answer indicated. The content is designed to test knowledge of programming syntax and logic.

Uploaded by

Zuker
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)
23 views6 pages

JavaScript MCQs on Control Structures

The document contains a series of multiple choice questions (MCQs) related to programming concepts, particularly focusing on control structures such as if statements, loops, and switch statements. Each question is accompanied by four answer options, with the correct answer indicated. The content is designed to test knowledge of programming syntax and logic.

Uploaded by

Zuker
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

📘 Multiple Choice Questions (MCQs)

1. Which keyword is used to execute code if a certain condition is

true?​

a) switch​

b) for​

c) if​

d) while​

👉 Answer: c)

2. What will the following code print?

let x = 10;

if (x > 5) {

[Link]("Yes");

} else {

[Link]("No");

}
a) No​

b) Yes​

c) undefined​

d) Error​

👉 Answer: b)

3. Which statement is used when multiple possible conditions need

to be checked?​

a) if … else​

b) switch​

c) for​

d) while​

👉 Answer: b)

4. How many times will the following loop execute?

for(let i = 0; i < 5; i++) {

[Link](i);

}
a) 4​

b) 5​

c) 6​

d) Infinite​

👉 Answer: b)

5. What is the difference between while and do-while loops?​

a) while loop executes at least once, do-while may not execute.​

b) do-while executes at least once, while may not execute.​

c) Both are the same.​

d) while is faster than do-while.​

👉 Answer: b)

6. What is the correct syntax for a switch statement?​

a)

switch(x) {

case 1: break;

case 2: break;

}
b)

switch x { case 1; case 2; }

c) switch x: case 1; break;​

d) switch (x) else {}​

👉 Answer: a)

7. Which statement can be used to exit a loop prematurely?​

a) continue​

b) break​

c) return​

d) exit​

👉 Answer: b)

8. What will the following code print?

let i = 0;

while(i < 3) {
[Link](i);

i++;

a) 0 1 2 3​

b) 0 1 2​

c) 1 2 3​

d) Infinite loop​

👉 Answer: b)

9. Which of the following is used to skip the current iteration and

continue with the next iteration?​

a) break​

b) continue​

c) return​

d) exit​

👉 Answer: b)

10. What will the following code print?

for(let i = 0; i < 3; i++) {


if(i === 1) continue;

[Link](i);

a) 0 1 2​

b) 0 2​

c) 1 2​

d) 0 1​

👉 Answer: b)

You might also like