Empowering Students with AI-Powered Assessments & Intelligent Learning
Chapter Exam

Chapter 6: Conditional Statements in PHP — Online MCQ Test

COMPUTER APPLICATIONS · CLASS 12th · Tamil Nadu State Board

Practice Chapter 6: Conditional Statements in PHP with a free chapter-wise online MCQ test for Tamil Nadu State Board CLASS 12th COMPUTER APPLICATIONS. This chapter covers: This chapter covers logical decision-making in PHP web development. Students examine control structures including if statements if-else conditions if-elseif-else chains and switch.... AI-generated questions from basic to board-exam level, with instant results and explanations.

10
Questions
20m
Time Limit
3
Attempts Left
  • 10 random questions from this chapter (mixed difficulty)
  • Questions you've seen before won't repeat until the pool resets
  • You have 20 minutes — exam auto-submits when time is up
  • Maximum 3 attempts per chapter
  • Results and explanations shown immediately after submission
Login to Start This Exam →

New here? Register free — includes 3 free chapter exams.

Chapter 6: Conditional Statements in PHP — Important Questions & Answers (FAQ)

Frequently asked questions from Tamil Nadu State Board CLASS 12th COMPUTER APPLICATIONS — Chapter 6: Conditional Statements in PHP, with answers and explanations. These are sample questions; the exam has its own separate question set.

Which PHP statement is used to execute a block of code only when a condition is true?
  • A. if ✓
  • B. switch
  • C. for
  • D. while
Answer: A. if
The if statement checks a condition and runs the code block only when the condition evaluates to true.
What is the correct syntax of an if statement in PHP?
  • A. if (condition) { statements; } ✓
  • B. if condition then { statements; }
  • C. if { condition } (statements);
  • D. if [condition] do statements;
Answer: A. if (condition) { statements; }
In PHP, the condition is placed inside parentheses and the statements are enclosed in curly braces.
What will be the output of the following code? <?php $x = 10; if ($x > 5) { echo 'Yes'; } ?>
  • A. Yes ✓
  • B. No
  • C. 10
  • D. Error
Answer: A. Yes
Since 10 is greater than 5, the condition is true and 'Yes' is displayed.
Choose the correct output: <?php $mark = 45; if ($mark >= 90) echo 'A'; elseif ($mark >= 50) echo 'B'; else echo 'C'; ?>
  • A. B
  • B. A
  • C. C ✓
  • D. 45
Answer: C. C
45 is neither 90 or above nor 50 or above, so the else part executes and prints 'C'.
Which of the following switch statements is syntactically correct in PHP?
  • A. switch($day) { case 1: echo 'Mon'; break; default: echo 'Invalid'; } ✓
  • B. switch $day { case 1 echo 'Mon'; break; }
  • C. switch($day) [ case 1 => echo 'Mon'; ]
  • D. switch($day) { case 1; echo 'Mon'; break }
Answer: A. switch($day) { case 1: echo 'Mon'; break; default: echo 'Invalid'; }
PHP switch syntax requires case labels with colons, and statements inside braces, with break commonly used after each case.

Choose Your Plan & Start Practising

All plans cover every subject and chapter of your registered grade.

Free
₹0
3 exams · 1 year
Start Free →
Active
₹350
12 exams · 1 year
Get Active →
Pro
₹899
Unlimited exams · 1 year
Get Pro →

Compare all plans in detail →