Any2Quiz
Quizzes / CBSE / Class 8 / ICT / Programming Basics

Conditional Statements Quiz - CBSE Class 8 ICT

Free practice quiz: Conditional Statements (CBSE Class 8 ICT). 20 multiple-choice questions with answers and explanations. Play online, no sign-up needed.

This CBSE Class 8 ICT practice quiz has 20 multiple-choice questions on Conditional Statements, and 20 of them come with an explanation. Try the 5 sample questions below (tap an option to check yourself), then play the full quiz online. No sign-up needed.

Start quiz: 20 questions, free

Sample questions

  1. What is a conditional statement in programming?

    Show answer

    Answer: B. A statement that executes based on a condition

    A conditional statement allows execution of certain parts of the code based on whether a condition is true or false, making it a key concept in programming.

  2. What will the following code print? if (true) { console.log('Yes'); } else { console.log('No'); }

    Show answer

    Answer: A. Yes

    Since the condition is 'true', the first block will execute, printing 'Yes' to the console.

  3. What will be the output of the following code block? var a = 10; if (a == 10) { console.log('Ten'); } else { console.log('Not Ten'); }

    Show answer

    Answer: A. Ten

    The value of a is equal to 10, so the condition is true, and 'Ten' will be printed.

  4. What will happen if none of the if or else-if conditions are satisfied?

    Show answer

    Answer: C. The else block will execute if present

    If all if and else-if conditions are false, the else block, if defined, will execute, allowing for a default action.

  5. How can an 'if' statement be terminated in programming?

    Show answer

    Answer: D. With a curly brace }

    An 'if' statement block in most programming languages is terminated by a curly brace to signify the end of the conditional block.

Take the full quiz

More questions in this quiz

Answers and explanations are in the full quiz.

  1. Which of the following is the correct syntax for an if statement?
  2. In programming, what does the else statement do?
  3. Which of the following statements is true about the 'if-else' structure?
  4. In which situation would you use a nested if statement?
  5. What will the following code output if x = 5? if (x > 10) { console.log('High'); } else { console.log('Low'); }
  6. Which operator is used to compare two values?
  7. What does an 'else-if' statement allow you to do?
  8. When might you want to use logical operators in conditional statements?
  9. Which of the following is an example of a logical OR operation?
  10. Why might you use the switch statement instead of if-else?
  11. What is the return type of a conditional statement?
  12. Which of the following is NOT a valid condition in an if statement?
  13. If 'x' equals 0, what will the output of the following code be? if (x) { console.log('True'); } else { console.log('False'); }
  14. What does a default case in a switch statement do?
  15. Which is a benefit of using a ternary operator?

More quizzes

Browse all Programming Basics quizzes

More to play

Daily ChallengeA new quiz every day. Keep your streak.HangmanGuess the word, letter by letter.Story QuestLearn through short interactive stories.All quizzesCBSE, ICSE, competitive exams and more.